Reputation: 3320
Is there a way to use the Select Case statment in VB.net for beginswith? Or do i have to use a long elseif? Example:
If text.StartsWith("/go") then
elseif test.StartsWith("/stop")
elseif test.StartsWith("/continue")
End If
But instead something like:
Select Case text
Case text.StartsWith("/go")
Case text.StartsWith("/stop")
Case text.StartsWith("/continue")
Case Else
End Select
End Sub
Upvotes: 7
Views: 8317
Reputation: 86525
You can do something like
Select Case True
Case text.StartsWith("/go")
...
Case text.StartsWith("/stop")
...
Case Else
End Select
Upvotes: 11
Reputation: 18797
Select Case True
Case text.startswith("/go") : messagebox.show("Go")
Case text.startswith("/stop") : messagebox.show("stop")
Case text.startswith("/continue") : messagebox.show("continue")
End Select
Upvotes: 4