Like Operator

Syntax:

str1 Like str2

Group:

Operator

Description:

Returns True if str1 matches pattern str2. The pattern in str2 is one or more of the special character sequences shown in the following table.

Characters)

Description

?

Match any single character.

*

Match zero or more characters.

#

Match a single digit (0-9).

[charlist]

Match any char in the list.

[!charlist]

Match any char not in the list.

Example:

Sub Main
  Debug.Print "abcdfgcdefg" Like "" ' False
  Debug.Print "abcdfgcdefg" Like "a*g" ' True
  Debug.Print "abcdfgcdefg" Like "a*cde*g" ' True
  Debug.Print "abcdfgcdefg" Like "a*cd*cd*g" ' True
  Debug.Print "abcdfgcdefg" Like "a*cd*cd*g" ' True
  Debug.Print "00aa" Like "####" ' False
  Debug.Print "00aa" Like "????" ' True
  Debug.Print "00aa" Like "##??" ' True
  Debug.Print "00aa" Like "*##*" ' True
  Debug.Print "hk" Like "hk*" ' True
End
Sub