Click to See Complete Forum and Search --> : Select case


vinod kadam
July 31st, 2000, 04:38 AM
Hello,
I want to give range like 0 to 100 for a case of select case statement in ASP using VBScript.How can i do it.
I tried the following -
1) select case ymax
case 0 - 100
case else
end select

Not working.

2) select case ymax
case 0 to 100
case else
end select
Giving an error -
Microsoft VBScript compilation error '800a0400'
Expected statement
How can i work on range?
Please reply.

Johnny101
July 31st, 2000, 10:38 AM
try this:

select case ymax
case ymax > 0 and ymax <= 100
'do your thing here
case else
'ymax was less than zero or greater than 100
end select




hope this helps,

John


John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org

vinod kadam
August 7th, 2000, 03:42 AM
Hello,

The solution you provided for the 'range' problem in "select case" of ASP+ is not working.

vinod.

Johnny101
August 7th, 2000, 05:54 PM
this works in VB, but not in ASP:

select case ymax
case is 0 then
'response.write "Number is between zero and a hundred."
else
'response.write "Number was less than zero."
end if
case else
'response.write "Number was not between 0 and 100."
end select




the "is" keyword isn't supported. looks like you will have to do something like this:

if ymax > 0 and ymax <= 100 then
response.write "It passed"
else
response.write "it failed."
end if




sorry.

john

John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org

gerardd
October 28th, 2007, 08:10 AM
Hi Vinod,

The VB6 'To' range doesn't work in VBScript.

Instead, try:


Select Case True
Case ymax >= 0 And ymax <= 100
'do your thing here
Case Else
'ymax was less than zero or greater than 100
End Select



Gerard

PeejAvery
October 28th, 2007, 09:19 AM
Welcome to the forums, Gerard. Please try to keep your posts relevant. This thread is over 7 years old!

hesterloli
May 25th, 2008, 02:31 PM
Hi. I think something like this may be what's needed. You have that you would like a range in the Select statement. Maybe something like this:

Select case yMax
Case True
window.event.returnValue = YmaxTest(yMax)
Case Else
End Select

Function YmaxTest(yMax)
On Error Resume Next
If yMax >= Clng(0) OR yMax <= CLng(100) Then
'Do what you want with yMax here
YmaxTest = True
Else
YmaxTest = False
End If
If Err.Number <> CLng(0) Then
'error message
YmaxTest = False
End If
End Function