CorString: CompareOrdinalEx

CompareOrdinalEx

Compares substrings of two specified String objects by evaluating the numeric values of the corresponding Char objects in each substring.



 Public Function CompareOrdinalEx(
	  ByRef StrA As String,
	  ByVal IndexA As Long,
	  ByRef StrB As String,
	  ByVal IndexB As Long,
	  ByVal Length ) As Long

Parameters

StrA
[ByRef] String. The first string to use in the comparison.
IndexA
[ByVal] Long. The position of the substring within StrA.
StrB
[ByRef] String. The second string to use in the comparison.
IndexB
[ByVal] Long. The position of the substring within StrB.
Length
[ByVal] Variant. The maximum number of characters in the substrings to compare.

Return Values

Long -  A 32-bit signed integer that indicates the lexical relationship between StrA and StrB, as shown in the following table
Value Condition
Less than zeroThe substring in the StrA parameter is less than the substring in the StrB parameter.
ZeroThe substrings are equal, or the Length parameter is zero.
Greater than zeroThe substring in StrA is greater than the substring in StrB.

Remarks

The IndexA, IndexB, and Length parameters must be nonnegative.

The number of characters compared is the lesser of the length of StrA less IndexA, the length of StrB less IndexB, and Length.

Exceptions

Exception Condition
ArgumentOutOfRangeException IndexA is greater than StrA length.
-or-
IndexB is greater than StrB length.
-or-
IndexA, IndexB, or Length is negative.
-or-
Either StrA or StrB is empty, and Length is greater than zero.

See Also

Project CorLib Overview

Class CorString Overview