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

Range in a case clause

Status
Not open for further replies.

agual

Programmer
Joined
Nov 1, 2001
Messages
77
Location
ES
I'm used to do in other basics (Quick Basic, FreeBasic, Powerbasic)
Code:
select case i
case 0 TO 20: ....
case 21 TO 30:....
case else
end select

VBS issues an error when it finds the first TO. What's the correct syntax?




Antoni
 
agual,

I believe the Select case statement does a comparison,
and doesn't check conditions

I suggest using the IF.. Then.. Else statement

Code:
if 0 <i And i < 20 Then
	MsgBox "Between 0 and 20"
Elseif 20 <i And i < 30 Then
	MsgBox "Between 20 and 30"
Else
	MsgBox "integer = " & i
End if

Good luck...


--------------------------------------
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs,
and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
 
PHV: You pointed me to the online version of the chm file i have. It says nothing about ranges, so i must suppose they are not possible in VBS.

K0b3: This is the solution i used....

Thanks all!

Antoni
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top