"like" and "not like" comparison

  • Thread starter Thread starter Henry
  • Start date Start date
H

Henry

I want to search a list of names, and I want to exclude any names like like
"NY." I know how to do this include names like "NY", but can't find any help
on "not like" expression. Thanks for your help.

Function NYTest(abc)
If abc = "NY" Then
NYTest = "NY"
Else: NYTest = "UNK"
End If

End Function
 
Henry said:
I want to search a list of names, and I want to exclude any names like like
"NY." I know how to do this include names like "NY", but can't find any
help
on "not like" expression. Thanks for your help.

Function NYTest(abc)
If abc = "NY" Then
NYTest = "NY"
Else: NYTest = "UNK"
End If

End Function


I'm not sure I understand you, because the code snippet you posted doesn't
use the Like operator at all. However, in principle you can use tests like
these:

Test for "like":

If abc Like "*NY*" Then
' abc contains the string "NY"
End If

Test for "not like":

If Not (abc Like "*NY*") Then
' abc does not contain the string "NY"
End If
 
Back
Top