Siebel VB Language Reference > VB Language Reference >
Like Operator
Like is a standard VB operator used to compare the contents of string expressions. Syntax
string LIKE pattern
|
|
string |
Any string or string expression |
pattern |
Any string expression to compare to string |
Returns
-1 (TRUE) if string matches pattern, 0 (FALSE) otherwise. Usage
pattern can include the following special characters:
|
|
? |
A single character |
* |
A set of zero or more characters |
# |
A single digit character (0-9) |
[chars] |
A single character in chars |
[!chars] |
A single character not in chars |
[startchar-endchar] |
A single character in the range startchar to endchar |
[!startchar-endchar] |
A single character not in the range startchar to endchar |
Both ranges and lists can appear within a single set of square brackets. Ranges are matched according to their ANSI values. In a range, startchar must be less than endchar. If either string or pattern is NULL, then the result value is NULL. The Like operator respects the current setting of Option Compare. For more information about operators, read Visual Basic (VB) Expressions. Example
This example tests whether a letter is lowercase. Sub Button_Click Dim userstr as String Dim revalue as Integer Dim msgtext as String Dim pattern pattern = "[a-z]" userstr = "E" retvalue = userstr LIKE pattern If retvalue = -1 then msgtext = "The letter " & userstr & " is lowercase." Else msgtext = "Not a lowercase letter." End If End Sub
Related Topics
InStr Function Option Compare Statement StrComp Function
|