Seems If I stack the Cases together they don't work as one. Since VB.NET Cases don't require the use of Exit Select
/ Return it seems to automatically put that every time a new Case is detected under it?
Dim Test as Integer = 12 Select Case Test Case 11 Case 12 Case 13 MsgBox.Show("Could be 11 or 12 or 13?") End Select
It doesn't seem to work only 13 works..
Gotta always remember this rule that you can't stack Cases like this from now on
It's not easy to remember it when porting applications.`
Your understanding is correct. VB will not "fall through".
Specify a single Case
and separate each expression with a comma:
Select Case Test Case 11, 12, 13 MsgBox.Show("Could be 11 or 12 or 13?") End Select
Alternatively, you could use a range with the To
keyword to accomplish the same thing:
Select Case Test Case 11 To 13 MsgBox.Show("Could be 11 or 12 or 13?") End Select
For more information, see the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With