In C I can assign default
to some existing switch
entry:
switch(c) {
default :
case 1:
break;
case 2 :
break;
}
Is there a similar possibility in VB's select statement?
use case Else
, it is same as default of c
syntax:
Select [ Case ] testexpression
[ Case expressionlist
[ statements ] ]
[ Case Else
[ elsestatements ] ]
End Select
e.g.
creamcake = TextBox1.Text
Select Case creamcake
Case "Eaten"
DietState = "Diet Ruined"
Case "Not Eaten"
DietState = "Diet Not Ruined"
Case Else
DietState = "Didn't check"
End Select
if you want to assign more than one case then example
Select Case agerange
Case 16 To 21
MsgBox “Still Young”
Case 50 To 64
MsgBox “Start Lying”
End Select
Select Object.Name.ToString()
Case "Name1"
'Do something
Case "Name2"
'Do something else
Case Else
'Do the default action
End Select
This question is the exact opposite of VB.NET Select...Case Statement Equivalent in C#
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