Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript - Select Case for 2 of the same options?

Status
Not open for further replies.

humbletech99

Programmer
Nov 22, 2005
155
GB
I have got a select case statement in which I need two or more options to be mapped to the same action, something like
Code:
Select Case strOption
    Case "abc" or "hjk"
        do something
    Case "xyz" or "sdf"
        do something else
    Case Else
        do last resort.
End Select

I really really don't want to have to have a separate Case block for each option as this would double all the code for each option.

I have checked the docs but cannot see a way of doing multiple cases at the same time.

Any guidance on this would be much appreciated.
 
You can use a comma instead of the or you're currently using.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
You're welcome, glad I could help [smile]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Just want to note one thing for you, make sure you are aware that the Select Case criteria enclosed in quotes is case sensitive.

So the following are different:

Case "foo"
Case "Foo"

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
yes I've noticed this, and have worked around it by Lcasing all input before the comparison... unless you know of another way?
 
That is how I do it to.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top