|
-
Jan 11th, 2006, 06:01 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Case or If Statement
I want to use a case or an if statement to launch IE to a certain website if the user is from a certain state.
I was trying to put together a case statement that went something like this but it is in the wrong format and I'm not sure it is possible to do this with case:
VB Code:
Select Case strState
Case AK or AL or AR
'Do Stuff
Case WA or WY or WV
'Do Stuff
Is this possible to make the case a list of values like this or should I be using if statements?
-
Jan 11th, 2006, 06:06 PM
#2
Re: Case or If Statement
use a comma instead of the "Or"
Case AK, AL, AR
quotes round them if they are not variables ofcourse
casey.
-
Jan 12th, 2006, 11:14 AM
#3
Thread Starter
Addicted Member
Re: Case or If Statement
Thanks, that worked...
Now I've got another problem with the case statement though. Here is my case statement. It is not setting strURL to the correct website for some reason when strState is either "AK" or "AL". When stepping through the code it skips over the 'strURL = "www.google.com"' part even when the state matches the state for that case.
VB Code:
Select Case strState
Case strState = "AK", "CO", "DC", "DE", "HI", "ID", "IL", "IN", "KY", "MA", "MD", "MI", "MN", "MT", "NC", "ND", "NJ", "NY", "NH", "OH", "PA", "SD", "TN", "UT", "VA", "WA", "WI", "WV", "WY"
strURL = "http://www.google.com"
Case strState = "AL", "AR", "AZ", "CA", "CT", "FL", "GA", "IA", "KS", "LA", "ME", "MO", "MS", "NE", "NH", "NM", "NV", "OK", "PR", "RI", "TX", "VT"
strURL = "http://www.yahoo.com"
End Select
Any ideas? All the other states work correctly just the first one in each case.
-
Jan 12th, 2006, 11:27 AM
#4
Re: Case or If Statement
Don't use
Case strState = "AK", "CO"
The first part is an expression, which evaluates to True or False. The Select Case statement would then be
Select Case "AK"
Case True, "CO"
VB Code:
Select Case strState
Case "AK", "CO", "DC", "DE", "HI", "ID", "IL", "IN", "KY", "MA", "MD", "MI", "MN", "MT", "NC", "ND", "NJ", "NY", "NH", "OH", "PA", "SD", "TN", "UT", "VA", "WA", "WI", "WV", "WY"
strURL = "http://www.google.com"
Case "AL", "AR", "AZ", "CA", "CT", "FL", "GA", "IA", "KS", "LA", "ME", "MO", "MS", "NE", "NH", "NM", "NV", "OK", "PR", "RI", "TX", "VT"
strURL = "http://www.yahoo.com"
End Select
-
Jan 12th, 2006, 11:49 AM
#5
Thread Starter
Addicted Member
Re: Case or If Statement
Thanks, that cleared it up...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|