Select Case Between Value

J

J-P-W

"Stock Value" Could be anything from 0 to a million or so, and might
include a decimal (12345.67)

I can't find how to do this:

Select Case StockValue
Case 0 To 30000
response.Write("Less than 30000")
Case 30000 To 80000
response.Write("30000 to 80000")
Case 80000 To 180000
response.Write("80000 to 180000")
Case Else ' > 180000
response.Write("Greater than 180000")
End Select

I also tried Case > 0 And <30000 .... and so on

Can anyone advise how to write this select script please?

Thank you

Jon
 
B

Bob Barrows [MVP]

J-P-W said:
"Stock Value" Could be anything from 0 to a million or so, and might
include a decimal (12345.67)

I can't find how to do this:

Select Case StockValue
Case 0 To 30000
response.Write("Less than 30000")

Atually, the To comparison would include 30000, so a value of 30000 would
make this true.
Case 30000 To 80000
response.Write("30000 to 80000")
Case 80000 To 180000
response.Write("80000 to 180000")
Case Else ' > 180000
response.Write("Greater than 180000")
End Select

I also tried Case > 0 And <30000 .... and so on

Can anyone advise how to write this select script please?

Thank you

Jon

In VB, what you've done would work. Unfortunately, this is not one of the
pieces of "syntactic sugar" that survived during the creation of vbscript.
However, there is a workaround:

Select Case True
Case (StockValue<30000)
Case (StockValue>=30000 and StockValue<80000)
etc.
End Select


You can also use
If ... then
ElseIf ... then
Else
End If

Bob Barrows
PS. you can download the vbscript documentation from here:
http://tinyurl.com/7rk6
 
S

Steven Burn

StockValue = 1000
Select Case True
Case StockValue <= 30000: response.Write "StockValue [" & StockValue & "]
IS Less than 30000<br><br>"
Case StockValue <= 80000: response.Write "StockValue [" & StockValue & "]
IS 30000 to 80000<br><br>"
Case StockValue <= 180000: response.Write "StockValue [" & StockValue & "]
IS 80000 to 180000<br><br>"
Case Else: response.Write "StockValue [" & StockValue & "] IS Greater than
180000<br><br>"
End Select

http://mysteryfcm.co.uk/misc/sc_stockvalue.asp

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
J

J-P-W

Thanks Steve, I guess the Select Case _True_ was what I need to read up
on! Regards
Steven said:
StockValue = 1000
Select Case True
Case StockValue <= 30000: response.Write "StockValue [" & StockValue & "]
IS Less than 30000<br><br>"
Case StockValue <= 80000: response.Write "StockValue [" & StockValue & "]
IS 30000 to 80000<br><br>"
Case StockValue <= 180000: response.Write "StockValue [" & StockValue & "]
IS 80000 to 180000<br><br>"
Case Else: response.Write "StockValue [" & StockValue & "] IS Greater than
180000<br><br>"
End Select

http://mysteryfcm.co.uk/misc/sc_stockvalue.asp

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

J-P-W said:
"Stock Value" Could be anything from 0 to a million or so, and might
include a decimal (12345.67)

I can't find how to do this:

Select Case StockValue
Case 0 To 30000
response.Write("Less than 30000")
Case 30000 To 80000
response.Write("30000 to 80000")
Case 80000 To 180000
response.Write("80000 to 180000")
Case Else ' > 180000
response.Write("Greater than 180000")
End Select

I also tried Case > 0 And <30000 .... and so on

Can anyone advise how to write this select script please?

Thank you

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top