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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case question 1

Status
Not open for further replies.

VBGuy2112

Programmer
Feb 19, 2002
58
US
I'm sure the solution is simple but I don't know so I must ask.

I have a select case statement and I want to test for a range of values. In VB, I can do the following:

Select Case strTestValue
Case "2950" To "2959"
Blah

Case "29500"
Blah

Case Else
Blah Blah

End Select

In VBScript, it doesn't seem to like "Case "2950" To "2959"." I'm only able to test for specific values. Is there different syntax that will allow testing for a range of values?

Thanks!
 
I would go with a if statement in this case. I don't think VBscript is capable of using logical operators in a case select statement
I could be very wrong though I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
Thanks for the reply. I will use the if structure as you suggested.
 
The TO keyword is NOT supported by VBS. See
However, you can still achieve the same functionality by restructuring it.

nTestValue = 2951
Select Case True
Case nTestValue >= 2950 And nTestValue <= 2959
MsgBox &quot;2950 to 2959&quot;
Case nTestValue = 29500
MsgBox &quot;29500&quot;
Case Else
MsgBox &quot;Else&quot;
End Select Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top