Microsoft Office Tutorials and References
In Depth Information
Figure 7-2. An InputBox dialog box
string Like pattern
returns True if string fits pattern , and False otherwise. (Actually, the expression
can also return Null .) We will describe pattern in a moment.
The type of string comparison that the Like operator uses depends upon the setting of the
Option Compare statement. There are two possibilities, one of which should be placed
in the Declarations section of a module (in the same place as Option Explicit ):
Option Compare Binary
Option Compare Text
Note that the default is Option Compare Binary .
Under Option Compare Binary , string comparison is in the order given by the ANSI
character code, as shown here:
A < B < . . . < Z < a < b < . . . < z < À < . . . < Ø < à < . . . < ø
Under Option Compare Text , string comparison is based on a case-insensitive sort
order (determined by your PC's locale setting). This gives a sort order as shown here:
A = a < À = à < B = b < . . . < Z = z < Ø = ø
By the way, the last item in the Text sort order is the "]" character, with ANSI value 91.
This is useful to know if you want to place an item last in alphabetical order—just
surround it with square brackets.
The pattern-matching features of the Like operator allow the use of wildcard characters,
character lists, or character ranges. For example:
?
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
For more details, check the VBA help file.
Search JabSto ::




Custom Search