示例1:一个产品ID号是否由一个字母以及3个数字组成
If ProductID Like "[A-Za-z][0-9][0-9][0-9]" Then Print "OK"
'或者:
If ProductID Like "[A-Za-z]###" Then Print "OK"
示例2:检查时间格式是否正确
Dim tmp As String
tmp = "12:35:56" Like "[0-2][0-3]:[0-5][0-9]:[0-5][0-9]" '返回 True
tmp = "25:35:56" Like "[0-2][0-3]:[0-5][0-9]:[0-5][0-9]" '返回 False
附:更多Like 运算符示例
Dim MyCheck
MyCheck = "aBBBa" Like "a*a" ' 返回 True
MyCheck = "F" Like "[A-Z]" ' 返回 True
MyCheck = "F" Like "[!A-Z]" ' 返回 False
MyCheck = "a 2a" Like "a#a" ' 返回 True
MyCheck = "aM5b" Like "a[L-P]#[!c-e]" ' 返回 True
MyCheck = "BAT123khg" Like "B?T*" ' 返回 True
MyCheck = "CAT123khg" Like "B?T*" ' 返回 False