StrComp Function


StrComp Function

Class

Microsoft.VisualBasic.Strings

Syntax

     Dim result As Integer = StrComp  (string1, string2[, compare]) 


string1 (required; String)

Any string expression.


string2 (required; String)

Any string expression.


compare (optional; CompareMethod constant)

Indicates the text comparison method. One of the following Microsoft.VisualBasic.CompareMethod enumeration values:

Value

Description

Binary

Performs a binary (case-sensitive) comparison

Text

Performs a text (case-insensitive) comparison


If omitted, the current Option Compare method in effect is used.

Description

The StrComp function determines whether two strings are equal and, if not, which of the two strings has the greater value. The following table identifies the return values.

Scenario

Return value

string1 < string2

-1

string1 = string2

0

string1 > string2

1

string1 or string2 is Null

Null


Usage at a Glance

  • Using the comparison operators <, <=, >, and >= to compare strings performs a character-by-character binary comparison.

  • The StrComp function can provide a significant performance improvement (in the neighborhood of 30 percent to 70 percent) over the comparison operators.

See Also

StrConv Function, StrDup Function, StrReverse Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net