Name
Like Operator
Syntax
result
=string
Likepattern
-
string
Use: Required
Data Type: String
The string to be tested against
pattern
-
pattern
Use: Required
Data Type: String
A series of characters used by the
Like
operator to determine ifstring
andpattern
match
Return Type
Boolean
Description
If string
matches
pattern
, result
is True
; otherwise,
result
is False
.
Rules at a Glance
If either
string
orpattern
isNothing
, thenresult
will beNothing
.The default comparison method for the
Like
operator is Binary. This can be overridden using theOption
Compare
statement.Binary comparison is based on comparing the internal binary number representing each character; this produces a case-sensitive comparison.
Text comparison, the alternative to binary comparison, is case insensitive; therefore, A = a.
The sort order is based on the code page currently being used, as determined by the Windows regional settings.
The following table describes the special characters to use when creating a pattern; all other characters match themselves.
Character |
Meaning |
---|---|
|
Any single character |
|
Zero or more characters |
|
Any single digit (0-9) |
|
Any single character in |
|
Any single character not in |
|
A zero-length string (“”) |
list
is used to match a group of characters inpattern
to a single character instring
and can contain almost all available characters, including digits.Use a hyphen (
-
) inlist
to create a range of characters to match a character in ...
Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.