SyntaxDim result As Boolean = string Like pattern
DescriptionThe Like operator indicates whether string matches pattern (true) or not (False). In general, characters match themselves; a pattern of "abc" matches a string of "abc." But there are a few special characters that enable generic pattern matching.
[list] Matches any single character in list [!list] Matches any single character except those in list The characters are used together to form patterns. For instance, the pattern "a?###" matches the letter a followed by any single character and then followed by three digits. The list character in square brackets may include a simple set of characters, like "[3kd]," but it can also use the hyphen (-) character to specify a range, such as "[a-m0-9]," which specifies the lowercase letters a through m or the digits 0 through 9. Use a hyphen at the beginning or end of list to match the hyphen character. To use special characters, such as #, as normal characters, enclose them in square brackets. Usage at a Glance
ExampleThe following example matches a U.S. Social Security number, which is three groups of digits, 3, 2, and 4 digits, respectively. The groups are separated by hyphens. Public Function IsSSN(ByVal testText As String) As Boolean If (testText Like "###-##-####") Then Return True Else Return False End if End Function |