Returns an Integer indicating the result of a string comparison.
StrComp(string1, string2[, compare]) |
The StrComp function syntax has these named arguments:
Part | Description |
string1 | Required. Any valid string expression. |
string2 | Required. Any valid string expression. |
compare |
Optional. Specifies the type of string comparison. The compare argument may be omitted or have 0 or 1 value. To perform binary comparison, specify 0 (default). To perform not case-sensitive textual comparison, specify 1. |
Return Values
If | StrComp returns |
string1 is less than string2 | -1 |
string1 is equal to string2 | 0 |
string1 is greater than string2 | 1 |
string1 or string2 is Null | Null |
This example uses the StrComp function to return the results of a string comparison. If the third argument is 1, a textual comparison is performed; if the third argument is 0 or omitted, a binary comparison is performed.
Dim MyStr1, MyStr2, MyComp |
See Also |
InStr Function |