Siebel VB Language Reference > VB Language Reference >

Like Operator

Like is a standard VB operator used to compare the contents of string expressions.


string LIKE pattern



Any string or string expression


Any string expression to compare to string


-1 (TRUE) if string matches pattern, 0 (FALSE) otherwise.


pattern can include the following special characters:



A single character


A set of zero or more characters


A single digit character (0-9)


A single character in chars


A single character not in chars


A single character in the range startchar to 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 VB Expressions.


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."
      msgtext = "Not a lowercase letter."
   End If
End Sub

See Also

InStr Function
Option Compare Statement
StrComp Function

Siebel VB Language Reference