Siebel VB Language Reference > Siebel VB Language Reference >

StrComp Function


This standard VB function compares two strings and returns an integer specifying the result of the comparison.

Syntax

StrComp(string1, string2[, compare])

Argument
Description
string1
An expression containing the first string to compare
string2
An expression containing the second string to compare
compare
An integer indicating the method of comparison, where:
0 = case-sensitive
1 = case-insensitive

Returns

One of the following values:

Value
Meaning
-1
string1 < string2
0
string1 = string2
>1
string1 > string2
Null
string1 = Null or string2 = Null

Usage

If compare is 0, a case-sensitive comparison based on the ANSI character set sequence is performed. If compare is 1, a case-insensitive comparison is done based upon the relative order of characters as determined by the country code setting for your computer. If this argument is omitted, the module-level default, as specified with Option Compare, is used.

The string1 and string2 arguments are both passed as variants. Therefore, any type of expression is supported. Numbers are automatically converted to strings.

Example

This example compares a user-entered string to the string Smith.

Option Compare Text
Sub Button_Click
   Dim lastname as String
   Dim smith as String
   Dim x as Integer
   smith = "Smith"
   lastname = "smith"
   x = StrComp(lastname,smith,1)
   If x = 0 then
      `You typed Smith or smith
      End If
End Sub

See Also

InStr Function
Option Compare Statement


 Siebel VB Language Reference
 Published: 18 June 2003