String LIKE Pattern

The pattern matching operator.


StringThe string you want to test (String).
PatternThe string pattern to match:
? - matches any single character
* - matches zero or more characters
# - matches any single digit (0-9)
/charlist/ - matches any single character in charlist
/!charlist/ - matches any single character not in charlist.

REMARKS
* This operator is equal in precedence to all the comparison operators.
* This operator will make a case insensitive comparison.
* The type of string comparison used depends on the Option Compare statement.
* For more information, refer to the Strings & Characters > LIKE Operator page.
* For the Microsoft documentation refer to docs.microsoft.com

Debug.Print "some text" Like "*"    '= True  
Debug.Print "ab__cd" Like "ab*cd" '= True
Debug.Print "ab-cd" Like "ab?cd" '= True
Debug.Print "ab1cd" Like "ab?cd" '= True
Debug.Print "ab1cd" Like "ab#cd" '= True
Debug.Print "---ab" Like " ""*ab" '= False
Debug.Print "123ab" Like "###ab" '= True
Debug.Print "123ab" Like "???ab" '= True
Debug.Print "123" Like "*" '= True
Debug.Print "abc" Like "###" '= False
Debug.Print "1" Like "/123/" '= False

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited Top