Contains will only accept a single value so you have to call it once for each value. The trick is to write your code such that you only write that call once but it gets executed multiple times. In the age of LINQ, you would do that like this:
Dim values = {"value1", "value2", "value3"}
If values.Any(Function(s) myString.Contains(s)) Then
'...
End If
The old-school option would be using a loop:
Dim values = {"value1", "value2", "value3"}
Dim containsAny = False
For Each value in values
If myString.Contains(value) Then
containsAny = True
Exit For
End If
Next
If containsAny Then
'...
End If
You could put either of those into a method:
Public Function ContainsAny(text As String, ParamArray values As String()) As Boolean
Return values.Any(Function(s) text.Contains(s))
End Function
Public Function ContainsAny(text As String, ParamArray values As String()) As Boolean
For Each value in values
If text.Contains(value) Then
Return True
End If
Next
Return False
End Function
and then call it like so:
Dim values = {"value1", "value2", "value3"}
If Me.ContainsAny(myString, values) Then
'...
End If
or like so:
If Me.ContainsAny(myString, "value1", "value2", "value3") Then
'...
End If
You could also write extension methods like so:
Imports System.Runtime.CompilerServices
Module StringExtensions
<Extension>
Public Function ContainsAny(source As String, ParamArray values As String()) As Boolean
Return values.Any(Function(s) source.Contains(s))
End Function
End Module
or like so:
Imports System.Runtime.CompilerServices
Module StringExtensions
<Extension>
Public Function ContainsAny(source As String, ParamArray values As String()) As Boolean
For Each value In values
If source.Contains(value) Then
Return True
End If
Next
Return False
End Function
End Module
and then call it like so:
Dim values = {"value1", "value2", "value3"}
If myString.ContainsAny(values) Then
'...
End If
or like so:
If myString.ContainsAny("value1", "value2", "value3") Then
'...
End If