I want to check if in a given text, there's one of several strings. e.g. ist "halt" OR "Stop" or "Wait" in my text then do something.
What does work if I use several elseifs. But I want a slimer more elegant Code
Both the subs down there work
Public Sub worksfine1(strText As String)
strText = LCase(strText)
If InStr(strText, "go") > 1 Then
Call DoStuff1(strText)
ElseIf InStr(strText, "wait") > 1 Then
Call DoStuff2(strText)
ElseIf InStr(strText, "stop") > 1 Then
Call DoStuff2(strText)
ElseIf InStr(strText, "halt") > 1 Then
Call DoStuff2(strText)
End If
End Sub
Public Sub worksfine2(strText As String)
strText = LCase(strText)
If InStr(strText, "go") > 1 Then
Call DoStuff1(strText)
ElseIf InStr(strText, "wait") > 1 Or InStr(strText, "stop") > 1 Or InStr(strText, "halt") > 1 Then
Call DoStuff2(strText)
End If
End Sub
What I want is something like
...
ElseIf InStr(strText, "wait", "stop", "halt") > 1 Then
Call DoStuff2(strText)
...
Is there an easy way, or do I have to live with the code above ?