Siebel VB Language Reference > Methods Reference for Siebel VB > String Methods >

Compare Strings Method


The Compare Strings method compares two strings. It returns one of the following integers. This integer describes the result of the comparison:

  • -1 (negative one). string1 is less than string2.
  • 0 (zero). string1 equals string2.
  • >1 (greater than one). string1 is greater than string2.
  • Null . string1 equals Null or string2 equals Null.

This method passes the values in the string1 argument and string2 argument as a variant. It supports any type of expression. It automatically converts a number to a string.

Format

StrComp(string1, string2[, compare])

The following table describes the arguments that you can use with this method.

Argument
Description

string1

An expression that contains the first string to compare.

string2

An expression that contains the second string to compare.

compare

An integer that specifies if the comparison is case-sensitive. You use one of the following values:

0. Case-sensitive. It performs a case-sensitive comparison according to the ANSI character set sequence.

1. Not case-sensitive. It performs a comparison that is not case-sensitive according to the relative order of characters. The country code setting for your computer determines this order.

If you do not include the compare argument, then this method uses the module-level default. The Set String Comparison method sets this default. For more information, see Set String Comparison Method.

Example

The following example compares a custom string to the Smith string:

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

Siebel VB Language Reference Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Legal Notices.