...

View Full Version : Select case



NancyJ
09-06-2005, 05:57 PM
total = 15.5 but it doesnt match any of the conditions


select case total
case total < 50
band = "fldBand1"
case total <100 and total >=50
band = "fldBand2"
case total >= 100
band = "fldBand3"
end select

nikkiH
09-06-2005, 06:44 PM
Silly question, but are you sure it's being stored as a number?

Try a
case "15.5" (with quotes) to see if it's treating it as text.

CrzySdrs
09-06-2005, 07:28 PM
This should be the correct syntax. Valid in VB so it should translate over nicely into ASP. Assuming that it is not a string as Nikki suggested.



Select Case total
Case Is >= 100
band = "fldBand3"
Case 50 To 100
band = "fldBand2"
Case Is < 50
band = "fldBand1"
End Select


They are reordered because that 100 was a problem. The 100 will be picked up by the first case and not the second.

neocool00
09-06-2005, 09:05 PM
Throw a Cint around total and see what happens ;)

NancyJ
09-07-2005, 12:24 PM
tried that and it didnt work, ended up doing a load of ifs :s

neocool00
09-07-2005, 02:07 PM
Ok, did some reading. With select case, it has to match, you can't do a range unless you do something like this:

Select Case myNumber
Case 0,1,2,3,4,5
...
Case 6,7,8,9,10
...
Case Else
...
End Select
Which obviously won't work for what you are trying to do, so unforunately, the best solution is the one you have (if..else).

nikkiH
09-07-2005, 03:03 PM
*smacks self on head*
Good to know. Thanks for posting that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum