例如:
Private Sub AllocateType(ByVal Command As String) Select Case Command Case "Eat" 'Call Eat procedure Case "Use" 'Call Use procedure Case "Quit" Case "Pause" Case "Go" Case Else Errors() 'Error handling procedure End Select End Sub
如果命令是’Brrrrr’,它将调用Errors().然而,如果命令是’Eat Food’,它仍然会调用Errors()并且不将参数传递给Eat程序.
编辑,因为它现在不起作用.
我已经尝试了所建议的内容,但我仍然有完全相同的问题.似乎Command.StartsWith和Command.Contains都不起作用,因为如果我尝试输入’Eat Food’,它仍然不会将其视为一个案例.
例:
Select Case Command Case Command.Contains("Eat") Output("TESTING") If Len(Command) > 4 Then Command = Mid(Command,4,(Len(Command) - 4)) Interaction(Command) Else Output("Eat What?") End If Case "Eat" Output("Eat What?") Case Command.StartsWith("Use") If Len(Command) > 4 Then Command = Mid(Command,(Len(Command) - 4)) Interaction(Command) Else Output("Use What?") End If Case "Use" Output("Use What?") 'Case Else ' Errors() End Select