This function compares two strings.
StrComp(string1, string2, [ compare])
Constant |
Value |
Description |
| vbBinaryCompare | 0 | Perform a binary comparison. |
| vbTextCompare | 1 | Perform a textual comparison. |
| vbDatabaseCompare | 2 | Not supported. |
The following table shows the return values of the StrComp function.
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 |
The StrComp function is more flexible than comparing two strings with the operators < and > because StrComp can do a binary comparison based on ASCII values or a text comparison based on letter order.