Multiple Case

  • Thread starter Thread starter Andre
  • Start date Start date
A

Andre

Hi,

Is there a way to make this work.

The Select case always enter in "Case Is > 0, Is < 1".
myReader.GetValue(0) return 8.4, but 8.4 is not between 0 and 1, so it
seem that the second part of the case does'nt work.

Select Case myReader.GetValue(0)
Case Is > 0, Is < 1
dr(3) = "red"
Case Is >= 1, Is < 2
dr(3) = "blue"
Case Is >= 2, Is < 3
dr(3) = "yellow"
[...]
End Select


Thank you.
 
Hi,

Is there a way to make this work.

The Select case always enter in "Case Is > 0, Is < 1".
myReader.GetValue(0) return 8.4, but 8.4 is not between 0 and 1, so
it
seem that the second part of the case does'nt work.

Select Case myReader.GetValue(0)
Case Is > 0, Is < 1
dr(3) = "red"
Case Is >= 1, Is < 2
dr(3) = "blue"
Case Is >= 2, Is < 3
dr(3) = "yellow"
[...]
End Select


Thank you.

I don't quite remember how vb.net works on this one, but can't you use And
or Or instead of the ,? Dont' remember what the comma does, but first
thought (intuition) is it means Or, which is why the first case runs (> 0
is true, so it matches that case)

Try
Select Case myReader.GetValue(0)
Case Is > 0 And Is < 1
dr(3) = "red"
Case Is >= 1 And Is < 2
dr(3) = "blue"
Case Is >= 2 And Is < 3
dr(3) = "yellow"
[...]
End Select
 
I don't quite remember how vb.net works on this one, but can't you use
And or Or instead of the ,? Dont' remember what the comma does, but
first thought (intuition) is it means Or, which is why the first case
runs (> 0 is true, so it matches that case)

Try
Select Case myReader.GetValue(0)
Case Is > 0 And Is < 1
dr(3) = "red"
Case Is >= 1 And Is < 2
dr(3) = "blue"
Case Is >= 2 And Is < 3
dr(3) = "yellow"
[...]
End Select

ah, found more documentation on this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmSelectCase.asp
 
Perfect, it's exactly what i was looking for.

Thank you.


Craig Deelsnyder said:
I don't quite remember how vb.net works on this one, but can't you use
And or Or instead of the ,? Dont' remember what the comma does, but
first thought (intuition) is it means Or, which is why the first case
runs (> 0 is true, so it matches that case)

Try
Select Case myReader.GetValue(0)
Case Is > 0 And Is < 1
dr(3) = "red"
Case Is >= 1 And Is < 2
dr(3) = "blue"
Case Is >= 2 And Is < 3
dr(3) = "yellow"
[...]
End Select

ah, found more documentation on this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmSelectCase.asp
 
Back
Top