By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,194 Members | 1,664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,194 IT Pros & Developers. It's quick & easy.

Select Case Between Value

P: n/a
"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

Jun 6 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <jo******@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
"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

Jun 6 '06 #2

P: n/a
Thanks Steve, I guess the Select Case _True_ was what I need to read up
on! Regards
Steven Burn wrote:
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" <jo******@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
"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


Jun 6 '06 #3

P: n/a
J-P-W wrote:
"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
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jun 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.