IIS ASP - Design advice

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > April 2005 > Design advice





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Design advice
dthmtlgod

2005-04-28, 7:55 am

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.




McKirahan

2005-04-28, 7:55 am

"dthmtlgod" <dvan@hotmail.com> wrote in message
news:#zZgkr#SFHA.2336@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.]


dthmtlgod

2005-04-28, 5:58 pm

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" <News@McKirahan.com> wrote in message
news:ib6dnT5nR5TIfO3fRVn-1g@comcast.com...
> "dthmtlgod" <dvan@hotmail.com> wrote in message
> news:#zZgkr#SFHA.2336@TK2MSFTNGP12.phx.gbl...
> cleanup
issues[vbcol=seagreen]
> to
of[vbcol=seagreen]
>
>
> 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.]
>
>



McKirahan

2005-04-28, 5:58 pm

"dthmtlgod" <dvan@hotmail.com> wrote in message
news:enniaz$SFHA.1148@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().


dthmtlgod

2005-04-28, 5:58 pm

Thanks, make sense now.


"McKirahan" <News@McKirahan.com> wrote in message
news:eLqdne5VY4NPbu3fRVn-jg@comcast.com...
> "dthmtlgod" <dvan@hotmail.com> wrote in message
> news:enniaz$SFHA.1148@tk2msftngp13.phx.gbl...
figure[vbcol=seagreen]
>
> 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().
>
>



dthmtlgod

2005-04-28, 5:58 pm

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" <News@McKirahan.com> wrote in message
news:eLqdne5VY4NPbu3fRVn-jg@comcast.com...
> "dthmtlgod" <dvan@hotmail.com> wrote in message
> news:enniaz$SFHA.1148@tk2msftngp13.phx.gbl...
figure[vbcol=seagreen]
>
> 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().
>
>



dthmtlgod

2005-04-28, 5:58 pm

Typos on my part mostly. I think I have it where it is workable. Thank you
again for your script.


"dthmtlgod" <dvan@hotmail.com> wrote in message
news:eyt1obATFHA.3312@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" <News@McKirahan.com> wrote in message
> news:eLqdne5VY4NPbu3fRVn-jg@comcast.com...
> figure
>
>



dthmtlgod

2005-04-28, 5:58 pm

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
****


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com