By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,979 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,979 IT Pros & Developers. It's quick & easy.

Design advice

P: n/a
I am creating a online help desk for my office. I am attempting to cleanup
my code and I was hoping for a little advice.

I have 30 different categories of requests ranging from the desktop issues
to application issues. I am using submit buttons on one version and a
dropdown/list box on the other. Both work the same.

All the items have the same name "cmdProblem". The value is then passed to
another form. This all works great.

I then have 30 "if" statements that ask a series of questions. A lot of
them ask the same questions, a few differ though. There is 1,800 lines of
code. Is there an easier way to do this?

PT = request.form("cmdProblem")

<% if ucase(pt) = "MONITOR" then %>

..... Code ....

I do this 30 times.


Jul 22 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"dthmtlgod" <dv**@hotmail.com> wrote in message
news:#z**************@TK2MSFTNGP12.phx.gbl...
I am creating a online help desk for my office. I am attempting to cleanup my code and I was hoping for a little advice.

I have 30 different categories of requests ranging from the desktop issues
to application issues. I am using submit buttons on one version and a
dropdown/list box on the other. Both work the same.

All the items have the same name "cmdProblem". The value is then passed to another form. This all works great.

I then have 30 "if" statements that ask a series of questions. A lot of
them ask the same questions, a few differ though. There is 1,800 lines of
code. Is there an easier way to do this?

PT = request.form("cmdProblem")

<% if ucase(pt) = "MONITOR" then %>

.... Code ....

I do this 30 times.

If I understand the issue ...

You could have a matrix defining which problem asks which questions;
then, for the given Problem, ask the associated questions. For example:

Dim arrP(30) '= Problems
arrP(1) = "Monitor"
arrP(2) = "Keyboard"
...
Dim booP
booP = False
Dim intP
Dim strP

Dim arrQ(10) '= Questions
arrQ(1) = "Size?"
arrQ(2) = "Resolution?"
arrQ(3) = "O/S?"
...

Dim arrX(20) '= Problem / Question Matrix
arrX(1) = "1,2"
...

Dim arrY
Dim intY
Dim strY

Dim Problem
Problem = Request.Form("Problem")

For intP = 1 To UBound(arrP)
If arrP(intP) = Problem Then
booP = True
Exit For
End If
Next

If booP Then
arrY = Split(arrX(intP),",")
strY = "Please answer the following questions about your '"
strY = strY & arrp(Problem) & "' problem:" & vbCrLf
For intY = 0 To UBound(arrY)
strY = strY & vbCrLf & arrQ(arrY(intY))
Next
Response.Write(strY)
Else
Response.Write("Invalid Problem! (" & Problem & ")")
End If
[ P.S. I know arrays are zero-based.]
Jul 22 '05 #2

P: n/a
Wow, thank you for this, I will give it a try. I should be able to figure
this out. I am horrible with arrays though.

What does the booP variable accomplish?
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:ib********************@comcast.com...
"dthmtlgod" <dv**@hotmail.com> wrote in message
news:#z**************@TK2MSFTNGP12.phx.gbl...
I am creating a online help desk for my office. I am attempting to

cleanup
my code and I was hoping for a little advice.

I have 30 different categories of requests ranging from the desktop issues to application issues. I am using submit buttons on one version and a
dropdown/list box on the other. Both work the same.

All the items have the same name "cmdProblem". The value is then passed

to
another form. This all works great.

I then have 30 "if" statements that ask a series of questions. A lot of
them ask the same questions, a few differ though. There is 1,800 lines of code. Is there an easier way to do this?

PT = request.form("cmdProblem")

<% if ucase(pt) = "MONITOR" then %>

.... Code ....

I do this 30 times.

If I understand the issue ...

You could have a matrix defining which problem asks which questions;
then, for the given Problem, ask the associated questions. For example:

Dim arrP(30) '= Problems
arrP(1) = "Monitor"
arrP(2) = "Keyboard"
...
Dim booP
booP = False
Dim intP
Dim strP

Dim arrQ(10) '= Questions
arrQ(1) = "Size?"
arrQ(2) = "Resolution?"
arrQ(3) = "O/S?"
...

Dim arrX(20) '= Problem / Question Matrix
arrX(1) = "1,2"
...

Dim arrY
Dim intY
Dim strY

Dim Problem
Problem = Request.Form("Problem")

For intP = 1 To UBound(arrP)
If arrP(intP) = Problem Then
booP = True
Exit For
End If
Next

If booP Then
arrY = Split(arrX(intP),",")
strY = "Please answer the following questions about your '"
strY = strY & arrp(Problem) & "' problem:" & vbCrLf
For intY = 0 To UBound(arrY)
strY = strY & vbCrLf & arrQ(arrY(intY))
Next
Response.Write(strY)
Else
Response.Write("Invalid Problem! (" & Problem & ")")
End If
[ P.S. I know arrays are zero-based.]

Jul 22 '05 #3

P: n/a
"dthmtlgod" <dv**@hotmail.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Wow, thank you for this, I will give it a try. I should be able to figure
this out. I am horrible with arrays though.

What does the booP variable accomplish?


I use hungarian notation (sort of) for variable name prefixes:

obj = object
int = integer (well, numeric anyway)
str = string
boo = boolean (i.e. True/False)

booP (if True) indicates that the Problem was found in arrP().
Jul 22 '05 #4

P: n/a
Thanks, make sense now.
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:eL********************@comcast.com...
"dthmtlgod" <dv**@hotmail.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Wow, thank you for this, I will give it a try. I should be able to figure this out. I am horrible with arrays though.

What does the booP variable accomplish?


I use hungarian notation (sort of) for variable name prefixes:

obj = object
int = integer (well, numeric anyway)
str = string
boo = boolean (i.e. True/False)

booP (if True) indicates that the Problem was found in arrP().

Jul 22 '05 #5

P: n/a
Getting very close to getting this to work. I am getting a Type Mismatch
Error, if I select a valid problem, works great if I select a problem not
listed.

Dim ArrP(3) '=Problems
arrP(1) = "TOWER"
arrP(2) = "MONITOR"
arrP(3) = "KEYBOARD"

Dim booP
booP = False

Dim intP
Dim strP

Dim arrQ(3) '=Questions
arrQ(1) = "Is it broke?"
arrQ(2) = "Type of hardware?"
arrQ(3) = "Any other info?"

Dim arrX(3) '=Problem/Questions
arrX(1) = "1,2,3"
arrX(2) = "2,3"
arrX(3) = "1,3"

Dim arrY
Dim intY
Dim strY

Dim Problem
Problem = request.form("cmdProblem")

For intP = 1 to UBound(arrP)
if arrP(intP) = Problem then
booP = true
exit for
end if
next

if booP then
arrY = Split(arrX(inpP), ", ")
strY = "Please answer the following questions about your '"

**** Getting it on this line
strY = strY & arrP(Problem) & "' problem: " & vbCrLF
*****
for intY = 0 to UnBound(arrY)
strY = strY & vbCrLF & arrQ(arrY(intY))
next
Response.write (strY)
else
response.write ("Invalid Problem (" & Problem & ")")
end if

%>

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:eL********************@comcast.com...
"dthmtlgod" <dv**@hotmail.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Wow, thank you for this, I will give it a try. I should be able to figure this out. I am horrible with arrays though.

What does the booP variable accomplish?


I use hungarian notation (sort of) for variable name prefixes:

obj = object
int = integer (well, numeric anyway)
str = string
boo = boolean (i.e. True/False)

booP (if True) indicates that the Problem was found in arrP().

Jul 22 '05 #6

P: n/a
Typos on my part mostly. I think I have it where it is workable. Thank you
again for your script.
"dthmtlgod" <dv**@hotmail.com> wrote in message
news:ey**************@TK2MSFTNGP12.phx.gbl...
Getting very close to getting this to work. I am getting a Type Mismatch
Error, if I select a valid problem, works great if I select a problem not
listed.

Dim ArrP(3) '=Problems
arrP(1) = "TOWER"
arrP(2) = "MONITOR"
arrP(3) = "KEYBOARD"

Dim booP
booP = False

Dim intP
Dim strP

Dim arrQ(3) '=Questions
arrQ(1) = "Is it broke?"
arrQ(2) = "Type of hardware?"
arrQ(3) = "Any other info?"

Dim arrX(3) '=Problem/Questions
arrX(1) = "1,2,3"
arrX(2) = "2,3"
arrX(3) = "1,3"

Dim arrY
Dim intY
Dim strY

Dim Problem
Problem = request.form("cmdProblem")

For intP = 1 to UBound(arrP)
if arrP(intP) = Problem then
booP = true
exit for
end if
next

if booP then
arrY = Split(arrX(inpP), ", ")
strY = "Please answer the following questions about your '"

**** Getting it on this line
strY = strY & arrP(Problem) & "' problem: " & vbCrLF
*****
for intY = 0 to UnBound(arrY)
strY = strY & vbCrLF & arrQ(arrY(intY))
next
Response.write (strY)
else
response.write ("Invalid Problem (" & Problem & ")")
end if

%>

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:eL********************@comcast.com...
"dthmtlgod" <dv**@hotmail.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Wow, thank you for this, I will give it a try. I should be able to figure this out. I am horrible with arrays though.

What does the booP variable accomplish?


I use hungarian notation (sort of) for variable name prefixes:

obj = object
int = integer (well, numeric anyway)
str = string
boo = boolean (i.e. True/False)

booP (if True) indicates that the Problem was found in arrP().


Jul 22 '05 #7

P: n/a
It is asking the questions as it should, it is not displaying the problem
though. Still getting a type mismatch error. Any ideas?

Dim ArrP(3) '=Problems
arrP(1) = "TOWER"
arrP(2) = "MONITOR"
arrP(3) = "KEYBOARD"

strY = "Please answer the following questions about your '"
**** Getting it on this line
strY = strY & arrP(Problem) & "' problem: " & vbCrLF
****
Jul 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.