Saturday, May 27, 2017

LIKE function

  1.  "*" – matches any number of characters
  2. "?" – matches any 1 character
  3. "[]"– matches any 1 character specified between the brackets
  4. "- "  matches any range of characters e.g. [a-z] matches any non-capital 1 letter of the alphabet
  5. "#" – matches any digit character

Matching against letters

If "My house number is 22" Like "*##" then
   Debug.Print "Match: String contains a 2 digit number"
End If


Matching against numbers

1
2
3
If "My house number is 22" Like "*##" then
   Debug.Print "Match: String contains a 2 digit number"
End If


Matching a phone number with either dashes or dots


1
"123-345-678" Like "###[-.]###[-.]###"

Matching a certain string within another string



1
"fewfwfewfwefdogfefweff" Like "*dog*"





No comments:

Post a Comment