Wild Cards Used to Build Patterns with Like : Like « String Functions « VBA / Excel / Access / Word






Wild Cards Used to Build Patterns with Like

 
Character      Matches         
*              Zero or more characters        
?              Any single character        
#              Any single digit (0-9)        
[list]         Any single character in the specified list        
[!list]        Any single character not in the specified list      


Sub str()
    Dim str1 As String
    str1 = "Exit"
    result = (str1 Like "E*")     'result holds False
    result = (str2 Like "E*")     'result holds True
    result = (str2 Like "?x?*")     'result holds True
    result = (str1 Like "##")     'result holds True
    result = (str2 Like "[E,e]*")     'result holds True
End Sub

 








Related examples in the same category

1.Use Like to compare strings