开发者

VB.net Select Case Statement with Beginswith

开发者 https://www.devze.com 2023-01-17 09:01 出处:网络
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:

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.Starts开发者_开发百科With("/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


You can do something like

Select Case True
    Case text.StartsWith("/go")
        ...
    Case text.StartsWith("/stop")
        ...
    Case Else
End Select


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
0

精彩评论

暂无评论...
验证码 换一张
取 消