The correct way to check if a string contains a character (or substring) is to use a function InStr(). It will return a unidirectional index of the position within the line where the text was found. Thus, a return value> 0 indicates a successful match. For instance:
If InStr(query, " ") > 0 Then
' query contains a space
End If
A function InStr()can also take three or four arguments. If you want to specify a starting index, use the version with three arguments:
If InStr(3, query, " ") > 0 Then
' query contains a space at or after the 3rd character
End If
( ), . , , . , , (1):
If InStr(1, query, "A", vbTextCompare) > 0 Then
' query contains "a" or "A"
End If