StrComp Function
Updated: August 2009
Returns a value indicating the result of a string comparison.
StrComp(string1, string2[, compare])
The following 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 MyStr1 = "ABCD" MyStr2 = "abcd" ' This is a textual comparison, so the comparison ' is case-insensitive. ' Returns 0. MyComp = StrComp(MyStr1, MyStr2, 1) ' This is a binary comparison. ' Returns -1. MyComp = StrComp(MyStr1, MyStr2, 0) ' This is a binary comparison because the last ' argument is omitted. ' Returns 1. MyComp = StrComp(MyStr2, MyStr1)
Community Additions
Show: