473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SELECT CASE in ASP???

Dear friends,

I am having a hard time understanding how to use a SELECT CASE in ASP. I
have used it in VB but never in ASP scripting.

Scenerio:

I have 2 textboxes on a form that I have to allow entry to one or the other
or Both at the same time. Now I tried to use an If ElseIf but it got too
hard to track, so now I am using a SELECT CASE Statement.

TEXBOX1 named strEnglish
TEXBOX2 named strFrench

My code:
<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

Select Case

Then I have no idea how to go from here, because I have 2 input textboxes to
follow.
I found this example but I do not know how to apply it to my situation as I
have to folow 2 textbox entries.

<%
UserName=request.form("UserName")
Select Case UserName
Case "Kathi"
Msg = "You deserve a break. Take the day off!"
Case "JD","Anne"
Msg = "Don't forget to call Kathi today!"
Case Else
Msg = "Do I know you?"
End Select
response.write Msg
%>

Can someone please help me out, a known tutorial, perhaps an example or just
plain good ole help please??

Thanks in advance,

~Newbie
Jul 19 '05 #1
17 14582
Newbie wrote on 07 aug 2004 in microsoft.public.inetserver.asp.general:

I am having a hard time understanding how to use a SELECT CASE in
ASP. I have used it in VB but never in ASP scripting.

Scenerio:

I have 2 textboxes on a form that I have to allow entry to one or the
other or Both at the same time. Now I tried to use an If ElseIf but
it got too hard to track, so now I am using a SELECT CASE Statement.

TEXBOX1 named strEnglish
TEXBOX2 named strFrench

My code:
<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

Select Case

Then I have no idea how to go from here, because I have 2 input
textboxes to follow.


It is not that I cannot dint a solution using select case in this case,
but it seems far more useful to know what you want to do with the two
strings.

Probably you do not want to use select case after all!!

<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

if strEnglish = strFrench then
t="This is very improbable"
else
t="Two different languages usually produce different strings"
end if
response.write t
%>

not tested, but it should be the same as:

<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

select case strEnglish
case strFrench
t="This is very improbable"
case else
t="Two different languages usually produce different strings"
end select
response.write t
%>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2
Function GetResult(str1,str2)
strkey = Trim(str1) & Trim(str2)
Select Case strkey
Case "WhatEver1"
GetResult = "Something1"
Case "WhatEver2"
GetResult = "Something2"
Case "WhatEver3"
GetResult = "Something3"
Case "WhatEver4"
GetResult = "Something4"
End Select
End Function

dlbjr
Pleading sagacious indoctrination!
Jul 19 '05 #3
This entire thing is rather embarrassing as I cannto get it to work.

I have 2 input strings that will contain URL's (the contents of the textbox
strings is a non-issue.

I have to allow the user to be able to enter into JUST the English OR Just
the FRENCH or be able to Enter into BOTH ENGLISH and FRENCH

I was using an IF ELSE statement but was having a hard time with it, as the
scenerio's conflicted.

Example:

If strEnglish<>empty AND strFrench <>empty Then 'Both have something inside
them
'ENTER BOTH INTO DB
End If

If strEnglish<>empty Then 'Just English has something
inside it
'ENTER JUST THE ENGLISH
End If

If strFrench<>empty Then 'Just French has something
inside it
'ENTER JUST THE FRENCH
End If
Now for BOTH of the string textbox inputs , it worked well, but if I just
entered on either ENGLISH or FRENCH, well it would not acknowledge it......

So I think that maybe I should be using a CASE SELECT..but now I have no
idea how to make that work for my code, especially in ASP.

SAD yet true...but willing to learn how to make it work..........but have
yet to find an example that will make me understand..perhaps I am making it
harder than it is...a usual problem of mine.;))

Can someone help me out here, as I am having a hard time to get this to
work.

Thanks in advance,

~Brad (NEWBIE to ASP CASE Selects)

"Newbie" <Ne****@helpme.com> wrote in message
news:Y0*********************@news20.bellglobal.com ...
Dear friends,

I am having a hard time understanding how to use a SELECT CASE in ASP. I
have used it in VB but never in ASP scripting.

Scenerio:

I have 2 textboxes on a form that I have to allow entry to one or the other or Both at the same time. Now I tried to use an If ElseIf but it got too
hard to track, so now I am using a SELECT CASE Statement.

TEXBOX1 named strEnglish
TEXBOX2 named strFrench

My code:
<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

Select Case

Then I have no idea how to go from here, because I have 2 input textboxes to follow.
I found this example but I do not know how to apply it to my situation as I have to folow 2 textbox entries.

<%
UserName=request.form("UserName")
Select Case UserName
Case "Kathi"
Msg = "You deserve a break. Take the day off!"
Case "JD","Anne"
Msg = "Don't forget to call Kathi today!"
Case Else
Msg = "Do I know you?"
End Select
response.write Msg
%>

Can someone please help me out, a known tutorial, perhaps an example or just plain good ole help please??

Thanks in advance,

~Newbie

Jul 19 '05 #4
This entire thing is rather embarrassing as I cannto get it to work.

I have 2 input strings that will contain URL's (the contents of the textbox
strings is a non-issue.

I have to allow the user to be able to enter into JUST the English OR Just
the FRENCH or be able to Enter into BOTH ENGLISH and FRENCH

I was using an IF ELSE statement but was having a hard time with it, as the
scenerio's conflicted.

Example:

If strEnglish<>empty AND strFrench <>empty Then 'Both have something inside
them
'ENTER BOTH INTO DB
End If

If strEnglish<>empty Then 'Just English has something
inside it
'ENTER JUST THE ENGLISH
End If

If strFrench<>empty Then 'Just French has something
inside it
'ENTER JUST THE FRENCH
End If
Now for BOTH of the string textbox inputs , it worked well, but if I just
entered on either ENGLISH or FRENCH, well it would not acknowledge it......

So I think that maybe I should be using a CASE SELECT..but now I have no
idea how to make that work for my code, especially in ASP.

SAD yet true...but willing to learn how to make it work..........but have
yet to find an example that will make me understand..perhaps I am making it
harder than it is...a usual problem of mine.;))

Can someone help me out here, as I am having a hard time to get this to
work.

Thanks in advance,

~Brad (NEWBIE to ASP CASE Selects)

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Newbie wrote on 07 aug 2004 in microsoft.public.inetserver.asp.general:

I am having a hard time understanding how to use a SELECT CASE in
ASP. I have used it in VB but never in ASP scripting.

Scenerio:

I have 2 textboxes on a form that I have to allow entry to one or the
other or Both at the same time. Now I tried to use an If ElseIf but
it got too hard to track, so now I am using a SELECT CASE Statement.

TEXBOX1 named strEnglish
TEXBOX2 named strFrench

My code:
<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

Select Case

Then I have no idea how to go from here, because I have 2 input
textboxes to follow.


It is not that I cannot dint a solution using select case in this case,
but it seems far more useful to know what you want to do with the two
strings.

Probably you do not want to use select case after all!!

<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

if strEnglish = strFrench then
t="This is very improbable"
else
t="Two different languages usually produce different strings"
end if
response.write t
%>

not tested, but it should be the same as:

<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

select case strEnglish
case strFrench
t="This is very improbable"
case else
t="Two different languages usually produce different strings"
end select
response.write t
%>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #5
If strEnglish<>empty AND strFrench<>empty Then
'Do Both
End If

If strEnglish<>empty Then
'Do JUSt the English one
ElseIF strFrench<>empty Then
'Do Just the French one
End If

I did not need to use a SELECT CASE........... I think I must have missed
something when Iw first wrote the IF ELSEIF

Well now it works for all scenerios,

Thanks again to all those for your input............it is always helpful

~Brad

www.webdevcreations.com

"Brad" <in**@webdevcreations.com> wrote in message
news:QJ*********************@news20.bellglobal.com ...
This entire thing is rather embarrassing as I cannto get it to work.

I have 2 input strings that will contain URL's (the contents of the textbox strings is a non-issue.

I have to allow the user to be able to enter into JUST the English OR Just
the FRENCH or be able to Enter into BOTH ENGLISH and FRENCH

I was using an IF ELSE statement but was having a hard time with it, as the scenerio's conflicted.

Example:

If strEnglish<>empty AND strFrench <>empty Then 'Both have something inside them
'ENTER BOTH INTO DB
End If

If strEnglish<>empty Then 'Just English has something
inside it
'ENTER JUST THE ENGLISH
End If

If strFrench<>empty Then 'Just French has something
inside it
'ENTER JUST THE FRENCH
End If
Now for BOTH of the string textbox inputs , it worked well, but if I just
entered on either ENGLISH or FRENCH, well it would not acknowledge it......
So I think that maybe I should be using a CASE SELECT..but now I have no
idea how to make that work for my code, especially in ASP.

SAD yet true...but willing to learn how to make it work..........but have
yet to find an example that will make me understand..perhaps I am making it harder than it is...a usual problem of mine.;))

Can someone help me out here, as I am having a hard time to get this to
work.

Thanks in advance,

~Brad (NEWBIE to ASP CASE Selects)

"Newbie" <Ne****@helpme.com> wrote in message
news:Y0*********************@news20.bellglobal.com ...
Dear friends,

I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting.

Scenerio:

I have 2 textboxes on a form that I have to allow entry to one or the other
or Both at the same time. Now I tried to use an If ElseIf but it got too hard to track, so now I am using a SELECT CASE Statement.

TEXBOX1 named strEnglish
TEXBOX2 named strFrench

My code:
<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

Select Case

Then I have no idea how to go from here, because I have 2 input

textboxes to
follow.
I found this example but I do not know how to apply it to my situation
as I
have to folow 2 textbox entries.

<%
UserName=request.form("UserName")
Select Case UserName
Case "Kathi"
Msg = "You deserve a break. Take the day off!"
Case "JD","Anne"
Msg = "Don't forget to call Kathi today!"
Case Else
Msg = "Do I know you?"
End Select
response.write Msg
%>

Can someone please help me out, a known tutorial, perhaps an example or

just
plain good ole help please??

Thanks in advance,

~Newbie


Jul 19 '05 #6
"Brad" <in**@webdevcreations.com> wrote in message
news:v6*********************@news20.bellglobal.com ...
If strEnglish<>empty AND strFrench<>empty Then
'Do Both
End If

If strEnglish<>empty Then
'Do JUSt the English one
ElseIF strFrench<>empty Then
'Do Just the French one
End If

I did not need to use a SELECT CASE........... I think I must have missed
something when Iw first wrote the IF ELSEIF

Well now it works for all scenerios,

Thanks again to all those for your input............it is always helpful


Doesn't the above logic indicate that all three cases (English, French and
both) will be executed when both English and French are present? I think
this is the logic you're after:

If Len(strEnglish & strFrench)=0 Then
'Neither is present
ElseIf Len(strEnglish)=0 Then
'French
ElseIf Len(strFrench)=0 Then
'English
Else
'Both
End If

IMPORTANT NOTE: Pay special attention to "ElseIf". It's one word, no spaces.
It's fundamentally different from "Else If", which denotes nested IF
statements. Also, are you actually using the IsEmpty() inspection function?
It doesn't do what I think you think it does. :)
Jul 19 '05 #7
Chris,

I ran into problems with my Logic thinking of If Else, rather than
IFELSE.....finding out the hard way that my If strEnglish<>empty did not
work, nor did the one for the french......

So I finally ended up with what yoru logic depicted.

Thanks for the help [IE: your Important Note;)) ],

~Brad

"Chris Hohmann" <no****@thankyou.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
"Brad" <in**@webdevcreations.com> wrote in message
news:v6*********************@news20.bellglobal.com ...
If strEnglish<>empty AND strFrench<>empty Then
'Do Both
End If

If strEnglish<>empty Then
'Do JUSt the English one
ElseIF strFrench<>empty Then
'Do Just the French one
End If

I did not need to use a SELECT CASE........... I think I must have missed something when Iw first wrote the IF ELSEIF

Well now it works for all scenerios,

Thanks again to all those for your input............it is always helpful
Doesn't the above logic indicate that all three cases (English, French and
both) will be executed when both English and French are present? I think
this is the logic you're after:

If Len(strEnglish & strFrench)=0 Then
'Neither is present
ElseIf Len(strEnglish)=0 Then
'French
ElseIf Len(strFrench)=0 Then
'English
Else
'Both
End If

IMPORTANT NOTE: Pay special attention to "ElseIf". It's one word, no

spaces. It's fundamentally different from "Else If", which denotes nested IF
statements. Also, are you actually using the IsEmpty() inspection function? It doesn't do what I think you think it does. :)

Jul 19 '05 #8
Chris,

Seems the logic is not working..............

It works very well for BOTH, but not for the rest, any ideas?

Perhaps I should use a CASE SELECT

How can I convert the logic you wrote to CASE SELECT

I cannot make it work with the IFELSE, it seems to crap out on the
individual entries, while the BOTh entries works fine.

Any ideas?

Thanks in advance,

~Brad
"Brad" <in**@webdevcreations.com> wrote in message
news:CX*********************@news20.bellglobal.com ...
Chris,

I ran into problems with my Logic thinking of If Else, rather than
IFELSE.....finding out the hard way that my If strEnglish<>empty did not
work, nor did the one for the french......

So I finally ended up with what yoru logic depicted.

Thanks for the help [IE: your Important Note;)) ],

~Brad

"Chris Hohmann" <no****@thankyou.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
"Brad" <in**@webdevcreations.com> wrote in message
news:v6*********************@news20.bellglobal.com ...
If strEnglish<>empty AND strFrench<>empty Then
'Do Both
End If

If strEnglish<>empty Then
'Do JUSt the English one
ElseIF strFrench<>empty Then
'Do Just the French one
End If

I did not need to use a SELECT CASE........... I think I must have missed something when Iw first wrote the IF ELSEIF

Well now it works for all scenerios,

Thanks again to all those for your input............it is always
helpful
Doesn't the above logic indicate that all three cases (English, French and both) will be executed when both English and French are present? I think
this is the logic you're after:

If Len(strEnglish & strFrench)=0 Then
'Neither is present
ElseIf Len(strEnglish)=0 Then
'French
ElseIf Len(strFrench)=0 Then
'English
Else
'Both
End If

IMPORTANT NOTE: Pay special attention to "ElseIf". It's one word, no

spaces.
It's fundamentally different from "Else If", which denotes nested IF
statements. Also, are you actually using the IsEmpty() inspection

function?
It doesn't do what I think you think it does. :)


Jul 19 '05 #9
Brad wrote on 07 aug 2004 in
microsoft.public.inetserver.asp.general:
Now for BOTH of the string textbox inputs , it worked well,
but if I just entered on either ENGLISH or FRENCH, well it
would not acknowledge it......

So I think that maybe I should be using a CASE SELECT..
but now I have no idea how to make that work for my code,
Use the "Elseif" clause:

If a="" AND b="" Then
'do what needs to be done if both are empty
Elseif a="" Then
'do what needs to be done if only a is empty
Elseif b="" Then
'do what needs to be done if only b is empty
Else
'do what needs to be done if both are filled
End If

The 'select case' is never necessary, it only gives a
better visual appearance and preferably one variable to
be tested for a lot of values and intervals.

The 'if-then..elseif-then..else..end if' is also pleasing
to the eye,[and therefore easily debuggable IMHO,]
if properly indented.
especially in ASP.


ASP is not a scripting language. We are talking vbscript
here, and wether this is done in a serverside ASP platform
or in IE clientside vbscript does not matter, if you do not
use specific ASP objects like Response or Server. Those
objects are not part of vbscript and are also available in
ASP j(ava)script etc.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #10
Evertjan. wrote:
Brad wrote on 07 aug 2004 in
microsoft.public.inetserver.asp.general:
Now for BOTH of the string textbox inputs , it worked well,
but if I just entered on either ENGLISH or FRENCH, well it
would not acknowledge it......

So I think that maybe I should be using a CASE SELECT..
but now I have no idea how to make that work for my code,


Use the "Elseif" clause:

If a="" AND b="" Then
'do what needs to be done if both are empty
Elseif a="" Then
'do what needs to be done if only a is empty
Elseif b="" Then
'do what needs to be done if only b is empty
Else
'do what needs to be done if both are filled
End If

The 'select case' is never necessary, it only gives a
better visual appearance and preferably one variable to
be tested for a lot of values and intervals.


The advantage of select case is that it utilizes short-circuit evaluation,
as opposed to If, in which all expressions are evaluated, which can lead to
errors if any of the expressions generate errors depending on the results of
earlier evaluations. I realize that this does not apply to this situation:
neither a="" nor b="" can generate an error so If a="" AND b="" Then is a
safe expression to use. If you were trying to evauate whether an object
variable was empty, Nothing, contained Null, or contained an empty string,
you would have to resort to nesting your boolean comparisons to avoid
errors. Using Select Case, however, no nesting is necessary. For example,
with recordsets, nested if statements are often used:

if not rs.eof then
if rs(0) is null then
elseif rs(0) ="" then
else
end if
end if

The nesting can get deep and is very often difficult to debug. Using Select
Case, however:

Select Case True
Case rs.eof
'code to handle empty recordset
Case rs(0) is Null
'code to handle case where the field contains null
Case rs(0) = ""
'code to handle case where the field contains ""
Case Else
'code which will only run when the field contains a value
End Case
HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #11
Bob Barrows [MVP] wrote on 08 aug 2004 in
microsoft.public.inetserver.asp.general:
Using Select Case, however, no nesting is necessary. For example,
with recordsets, nested if statements are often used:

if not rs.eof then
if rs(0) is null then
elseif rs(0) ="" then
else
end if
end if

The nesting can get deep and is very often difficult to debug. Using
Select Case, however:

Select Case True
Case rs.eof
'code to handle empty recordset
Case rs(0) is Null
'code to handle case where the field contains null
Case rs(0) = ""
'code to handle case where the field contains ""
Case Else
'code which will only run when the field contains a value
End Case


Ah, the "reversed select case" method. ;-)

I think, Bob, that also here 'Select Case' is just a shorthand version if
the 'elsif', also here no nesting is necessary:

If rs.eof Then
'code to handle empty recordset
Elseif rs(0) is Null Then
'code to handle case where the field contains null
Elseif rs(0) = "" Then
'code to handle case where the field contains ""
Else
'code which will only run when the field contains a value
End If

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #12
"Brad" wrote in message
news:_o*********************@news20.bellglobal.com ...
: Seems the logic is not working..............

You're right. Why would anyone need to enter a form in two languages?

However...

dim strEnglish, strFrench, strLanguage
strEnglish = ""
strFrench = ""
strLanguage = "both"

strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

if strEnglish <> "" and strFrench <> "" then
strLanguage = "both"
elseif strEnglish <> "" then
strLanguage = "English"
elseif strFrench <> "" then
strLanguage = "French"
else
' some other language
end if

or modify the form to accept English, French or both [English and French].
Then...

dim strLanguage
strLanguage = Response.Form("strLanguage")

select case strLanguage
case "both"
' English and French
case "English"
' English
case "French"
' French
case else
' Some other language
end select

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #13
Good evening Bob,

Now using the SELECT CASE (Reverse), and experiencing some issues:

My Code:

Select Case True
Case (strLink_e="" AND strLink_f="")
'ERROR message
Case (strLink_f="")
'User has entered an English URL string into Textbox
Case (strLink_e="")
'User has entered an French URL string into Textbox
Case Else
'User has entered into BOTH textboxs
End Select

Now, I have an Entry form , then a second form once the user has entered
into the first Entry form and clicked the SUBMIT button.

On all the Case Selects I see my DB working from the functionality of each
Case Select. However , I am experiencing a problem with the second form
page displaying itself for either just an English entriy OR just a French
entry...but when BOTH are entered.it works great (is displayed)

Any ideas why this would only work for BOTH , and not work for one OR the
other?

So, just to recap.

I have an Entry form:

Submit button

URL English TEXTBOX
URL French TEXTBOX
+++++++++++++++++++++++++++++++

Once the user enters his/her entry and clicks the Submit button,

Then I have another FORM that is called that will display the URL entered as
well as other info.

+++++++++++++++++++++++++++++++

However, this form seems to only reveal itself when the user has entered
into BOTH textboxes........if they enter into one OR the other.the
functionality that sits behind the chosen textbox entry works fine, yet the
second form does not display....

Do not know why??

Any ideas?

Thanks in advance,

~Brad


"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:e4*************@TK2MSFTNGP10.phx.gbl...
Evertjan. wrote:
Brad wrote on 07 aug 2004 in
microsoft.public.inetserver.asp.general:
Now for BOTH of the string textbox inputs , it worked well,
but if I just entered on either ENGLISH or FRENCH, well it
would not acknowledge it......

So I think that maybe I should be using a CASE SELECT..
but now I have no idea how to make that work for my code,
Use the "Elseif" clause:

If a="" AND b="" Then
'do what needs to be done if both are empty
Elseif a="" Then
'do what needs to be done if only a is empty
Elseif b="" Then
'do what needs to be done if only b is empty
Else
'do what needs to be done if both are filled
End If

The 'select case' is never necessary, it only gives a
better visual appearance and preferably one variable to
be tested for a lot of values and intervals.


The advantage of select case is that it utilizes short-circuit evaluation,
as opposed to If, in which all expressions are evaluated, which can lead

to errors if any of the expressions generate errors depending on the results of earlier evaluations. I realize that this does not apply to this situation:
neither a="" nor b="" can generate an error so If a="" AND b="" Then is a
safe expression to use. If you were trying to evauate whether an object
variable was empty, Nothing, contained Null, or contained an empty string,
you would have to resort to nesting your boolean comparisons to avoid
errors. Using Select Case, however, no nesting is necessary. For example,
with recordsets, nested if statements are often used:

if not rs.eof then
if rs(0) is null then
elseif rs(0) ="" then
else
end if
end if

The nesting can get deep and is very often difficult to debug. Using Select Case, however:

Select Case True
Case rs.eof
'code to handle empty recordset
Case rs(0) is Null
'code to handle case where the field contains null
Case rs(0) = ""
'code to handle case where the field contains ""
Case Else
'code which will only run when the field contains a value
End Case
HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #14
I don't have enough information. I have no idea what "works great" and
"doesn't work" mean. I have no idea what code is running in each branch of
the select case statement.

It sounds as if you need to do some debugging to find out what your
variables contain at each step of the operation. Use alert() in your
cliinet-side code and response.write in your server-side code to figure
outwhat's going on.

Bob Barrows

Brad wrote:
Good evening Bob,

Now using the SELECT CASE (Reverse), and experiencing some issues:

My Code:

Select Case True
Case (strLink_e="" AND strLink_f="")
'ERROR message
Case (strLink_f="")
'User has entered an English URL string into Textbox
Case (strLink_e="")
'User has entered an French URL string into Textbox
Case Else
'User has entered into BOTH textboxs
End Select

Now, I have an Entry form , then a second form once the user has
entered into the first Entry form and clicked the SUBMIT button.

On all the Case Selects I see my DB working from the functionality of
each Case Select. However , I am experiencing a problem with the
second form page displaying itself for either just an English entriy
OR just a French entry...but when BOTH are entered.it works great
(is displayed)

Any ideas why this would only work for BOTH , and not work for one OR
the other?

So, just to recap.

I have an Entry form:

Submit button

URL English TEXTBOX
URL French TEXTBOX
+++++++++++++++++++++++++++++++

Once the user enters his/her entry and clicks the Submit button,

Then I have another FORM that is called that will display the URL
entered as well as other info.

+++++++++++++++++++++++++++++++

However, this form seems to only reveal itself when the user has
entered into BOTH textboxes........if they enter into one OR the
other.the functionality that sits behind the chosen textbox entry
works fine, yet the second form does not display....

Do not know why??

Any ideas?

Thanks in advance,

~Brad


"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:e4*************@TK2MSFTNGP10.phx.gbl...
Evertjan. wrote:
Brad wrote on 07 aug 2004 in
microsoft.public.inetserver.asp.general:

Now for BOTH of the string textbox inputs , it worked well,
but if I just entered on either ENGLISH or FRENCH, well it
would not acknowledge it......

So I think that maybe I should be using a CASE SELECT..
but now I have no idea how to make that work for my code,

Use the "Elseif" clause:

If a="" AND b="" Then
'do what needs to be done if both are empty
Elseif a="" Then
'do what needs to be done if only a is empty
Elseif b="" Then
'do what needs to be done if only b is empty
Else
'do what needs to be done if both are filled
End If

The 'select case' is never necessary, it only gives a
better visual appearance and preferably one variable to
be tested for a lot of values and intervals.


The advantage of select case is that it utilizes short-circuit
evaluation, as opposed to If, in which all expressions are
evaluated, which can lead to errors if any of the expressions
generate errors depending on the results of earlier evaluations. I
realize that this does not apply to this situation: neither a="" nor
b="" can generate an error so If a="" AND b="" Then is a safe
expression to use. If you were trying to evauate whether an object
variable was empty, Nothing, contained Null, or contained an empty
string, you would have to resort to nesting your boolean comparisons
to avoid errors. Using Select Case, however, no nesting is
necessary. For example, with recordsets, nested if statements are
often used:

if not rs.eof then
if rs(0) is null then
elseif rs(0) ="" then
else
end if
end if

The nesting can get deep and is very often difficult to debug. Using
Select Case, however:

Select Case True
Case rs.eof
'code to handle empty recordset
Case rs(0) is Null
'code to handle case where the field contains null
Case rs(0) = ""
'code to handle case where the field contains ""
Case Else
'code which will only run when the field contains a value
End Case
HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #15
case info is usually sent vit the url in a querystring or in a hidden form variable. I'll do the querystring example for you but the hidden form field is just as easy.
the Url you are passing http://www.somedomain.com?lan=English

select case request.querystring("lan")

case "English"
do something here
case "French"
do something here
case else
do something here
end select

thats pretty much it - the case else statement is a default if nothing else is chosen

Hope that helps
- Bastard

On Sat, 7 Aug 2004 17:21:54 -0400, "Brad" <in**@webdevcreations.com> wrote:
This entire thing is rather embarrassing as I cannto get it to work.

I have 2 input strings that will contain URL's (the contents of the textbox
strings is a non-issue.

I have to allow the user to be able to enter into JUST the English OR Just
the FRENCH or be able to Enter into BOTH ENGLISH and FRENCH

I was using an IF ELSE statement but was having a hard time with it, as the
scenerio's conflicted.

Example:

If strEnglish<>empty AND strFrench <>empty Then 'Both have something inside
them
'ENTER BOTH INTO DB
End If

If strEnglish<>empty Then 'Just English has something
inside it
'ENTER JUST THE ENGLISH
End If

If strFrench<>empty Then 'Just French has something
inside it
'ENTER JUST THE FRENCH
End If
Now for BOTH of the string textbox inputs , it worked well, but if I just
entered on either ENGLISH or FRENCH, well it would not acknowledge it......

So I think that maybe I should be using a CASE SELECT..but now I have no
idea how to make that work for my code, especially in ASP.

SAD yet true...but willing to learn how to make it work..........but have
yet to find an example that will make me understand..perhaps I am making it
harder than it is...a usual problem of mine.;))

Can someone help me out here, as I am having a hard time to get this to
work.

Thanks in advance,

~Brad (NEWBIE to ASP CASE Selects)

"Newbie" <Ne****@helpme.com> wrote in message
news:Y0*********************@news20.bellglobal.co m...
Dear friends,

I am having a hard time understanding how to use a SELECT CASE in ASP. I
have used it in VB but never in ASP scripting.

Scenerio:

I have 2 textboxes on a form that I have to allow entry to one or the

other
or Both at the same time. Now I tried to use an If ElseIf but it got too
hard to track, so now I am using a SELECT CASE Statement.

TEXBOX1 named strEnglish
TEXBOX2 named strFrench

My code:
<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

Select Case

Then I have no idea how to go from here, because I have 2 input textboxes

to
follow.
I found this example but I do not know how to apply it to my situation as

I
have to folow 2 textbox entries.

<%
UserName=request.form("UserName")
Select Case UserName
Case "Kathi"
Msg = "You deserve a break. Take the day off!"
Case "JD","Anne"
Msg = "Don't forget to call Kathi today!"
Case Else
Msg = "Do I know you?"
End Select
response.write Msg
%>

Can someone please help me out, a known tutorial, perhaps an example or

just
plain good ole help please??

Thanks in advance,

~Newbie


Jul 19 '05 #16
After running m Debug code, I found that my problem was not within my SELECT
CASE. I was passing many varaibles and one of the varaibles, I changed the
name of it (as the IE: intNewID, where this would come after an INSERT to my
DB, returned from my Stored Procedure as an OUTPUT param.

The bottom line, the SELECT CASE or IF ELSEIF..... Both worked properlly, as
soon as I ran through using Response.Write ... Reponse.Flush, I found that
I was not making my intNewID available to the page, thus the reason why I
could not get the second FORM page to display itself.

Well all is well now,

Thanks to everyone for their input,

~Brad
;)

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
I don't have enough information. I have no idea what "works great" and
"doesn't work" mean. I have no idea what code is running in each branch of
the select case statement.

It sounds as if you need to do some debugging to find out what your
variables contain at each step of the operation. Use alert() in your
cliinet-side code and response.write in your server-side code to figure
outwhat's going on.

Bob Barrows

Brad wrote:
Good evening Bob,

Now using the SELECT CASE (Reverse), and experiencing some issues:

My Code:

Select Case True
Case (strLink_e="" AND strLink_f="")
'ERROR message
Case (strLink_f="")
'User has entered an English URL string into Textbox
Case (strLink_e="")
'User has entered an French URL string into Textbox
Case Else
'User has entered into BOTH textboxs
End Select

Now, I have an Entry form , then a second form once the user has
entered into the first Entry form and clicked the SUBMIT button.

On all the Case Selects I see my DB working from the functionality of
each Case Select. However , I am experiencing a problem with the
second form page displaying itself for either just an English entriy
OR just a French entry...but when BOTH are entered.it works great
(is displayed)

Any ideas why this would only work for BOTH , and not work for one OR
the other?

So, just to recap.

I have an Entry form:

Submit button

URL English TEXTBOX
URL French TEXTBOX
+++++++++++++++++++++++++++++++

Once the user enters his/her entry and clicks the Submit button,

Then I have another FORM that is called that will display the URL
entered as well as other info.

+++++++++++++++++++++++++++++++

However, this form seems to only reveal itself when the user has
entered into BOTH textboxes........if they enter into one OR the
other.the functionality that sits behind the chosen textbox entry
works fine, yet the second form does not display....

Do not know why??

Any ideas?

Thanks in advance,

~Brad


"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:e4*************@TK2MSFTNGP10.phx.gbl...
Evertjan. wrote:
Brad wrote on 07 aug 2004 in
microsoft.public.inetserver.asp.general:

> Now for BOTH of the string textbox inputs , it worked well,
> but if I just entered on either ENGLISH or FRENCH, well it
> would not acknowledge it......
>
> So I think that maybe I should be using a CASE SELECT..
> but now I have no idea how to make that work for my code,

Use the "Elseif" clause:

If a="" AND b="" Then
'do what needs to be done if both are empty
Elseif a="" Then
'do what needs to be done if only a is empty
Elseif b="" Then
'do what needs to be done if only b is empty
Else
'do what needs to be done if both are filled
End If

The 'select case' is never necessary, it only gives a
better visual appearance and preferably one variable to
be tested for a lot of values and intervals.
The advantage of select case is that it utilizes short-circuit
evaluation, as opposed to If, in which all expressions are
evaluated, which can lead to errors if any of the expressions
generate errors depending on the results of earlier evaluations. I
realize that this does not apply to this situation: neither a="" nor
b="" can generate an error so If a="" AND b="" Then is a safe
expression to use. If you were trying to evauate whether an object
variable was empty, Nothing, contained Null, or contained an empty
string, you would have to resort to nesting your boolean comparisons
to avoid errors. Using Select Case, however, no nesting is
necessary. For example, with recordsets, nested if statements are
often used:

if not rs.eof then
if rs(0) is null then
elseif rs(0) ="" then
else
end if
end if

The nesting can get deep and is very often difficult to debug. Using
Select Case, however:

Select Case True
Case rs.eof
'code to handle empty recordset
Case rs(0) is Null
'code to handle case where the field contains null
Case rs(0) = ""
'code to handle case where the field contains ""
Case Else
'code which will only run when the field contains a value
End Case
HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #17
Thanks for your input,

Very much appraciated,

I figured out my problem, via debugging the page, my SLECT CASE , nor
original IF ELSEIF, were not where the problem arose. It was a variable
that was not being seen

Thanbks again,

~BRAD

"Bã§TãRÐ" <no****@msn.com> wrote in message
news:tv********************************@4ax.com...
case info is usually sent vit the url in a querystring or in a hidden form variable. I'll do the querystring example for you but the hidden form field
is just as easy. the Url you are passing http://www.somedomain.com?lan=English

select case request.querystring("lan")

case "English"
do something here
case "French"
do something here
case else
do something here
end select

thats pretty much it - the case else statement is a default if nothing else is chosen
Hope that helps
- Bastard

On Sat, 7 Aug 2004 17:21:54 -0400, "Brad" <in**@webdevcreations.com> wrote:
This entire thing is rather embarrassing as I cannto get it to work.

I have 2 input strings that will contain URL's (the contents of the textboxstrings is a non-issue.

I have to allow the user to be able to enter into JUST the English OR Justthe FRENCH or be able to Enter into BOTH ENGLISH and FRENCH

I was using an IF ELSE statement but was having a hard time with it, as thescenerio's conflicted.

Example:

If strEnglish<>empty AND strFrench <>empty Then 'Both have something insidethem
'ENTER BOTH INTO DB
End If

If strEnglish<>empty Then 'Just English has something
inside it
'ENTER JUST THE ENGLISH
End If

If strFrench<>empty Then 'Just French has something
inside it
'ENTER JUST THE FRENCH
End If
Now for BOTH of the string textbox inputs , it worked well, but if I just
entered on either ENGLISH or FRENCH, well it would not acknowledge it......
So I think that maybe I should be using a CASE SELECT..but now I have no
idea how to make that work for my code, especially in ASP.

SAD yet true...but willing to learn how to make it work..........but have
yet to find an example that will make me understand..perhaps I am making itharder than it is...a usual problem of mine.;))

Can someone help me out here, as I am having a hard time to get this to
work.

Thanks in advance,

~Brad (NEWBIE to ASP CASE Selects)

"Newbie" <Ne****@helpme.com> wrote in message
news:Y0*********************@news20.bellglobal.co m...
Dear friends,

I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting.

Scenerio:

I have 2 textboxes on a form that I have to allow entry to one or the

other
or Both at the same time. Now I tried to use an If ElseIf but it got too hard to track, so now I am using a SELECT CASE Statement.

TEXBOX1 named strEnglish
TEXBOX2 named strFrench

My code:
<%
strEnglish=Request.Form("strEnglish")
strFrench=Request.Form("strFrench")

Select Case

Then I have no idea how to go from here, because I have 2 input
textboxesto
follow.
I found this example but I do not know how to apply it to my situation
asI
have to folow 2 textbox entries.

<%
UserName=request.form("UserName")
Select Case UserName
Case "Kathi"
Msg = "You deserve a break. Take the day off!"
Case "JD","Anne"
Msg = "Don't forget to call Kathi today!"
Case Else
Msg = "Do I know you?"
End Select
response.write Msg
%>

Can someone please help me out, a known tutorial, perhaps an example or

just
plain good ole help please??

Thanks in advance,

~Newbie

Jul 19 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
9
by: Kevin | last post by:
Hi, I am getting a syntax error Microsoft VBScript compilation error '800a03ea' Syntax error On the code below. The error references the "End Select" line Can anyone help me with what I am...
8
by: Penny | last post by:
Hi all, My browser throws this Select Case block back at me pointing out a syntax error on the line: 'Case < 251', between the word 'Case' and the '<' symbol. *************************** ...
10
by: MLH | last post by:
Suppose the following... Dim A as Date A=#7/24/2005# I wish to compare value of A against 2 other values: 1) 8/1/2005 2) 9/1/2005 Which is better and why... First:
7
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
3
by: Rob Meade | last post by:
Ok - I *think* this is only different in .net 2.0 - as I've not had any problems in the past, but then maybe I've not tried it... I have a value being read from an xml file where the value maybe...
8
by: | last post by:
Hello, This is gonna sound real daft, but how do I test a Select Case statement for variants of a theme? Here's a snippet of my code... Select Case sUsr Case "Guest", "TsInternetUser",...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
4
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie in php and I got error in my index.php which is: 1054 - Unknown column 'p.products_id' in 'on clause' select p.products_image, pd.products_name, p.products_id,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.