StringComparer: Compare |
Compares two values relative to each other in an ordered set.
Public Function Compare( ByRef x As Variant, ByRef y As Variant ) As Long
If the x and y parameter values are considered equal then zero should be returned. If the x parameter is considered less than the y parameter in relative order then a negative value should be returned. Otherwise, the x parameter is considered greater than the y parameter and should return a positive value. There is no specific positive or negative value that is defined as the expected value, only the sign of the value is regarded.
The example is the implementation used by the StringComparer.Ordinal and StringComparer.OrdinalIgnoreCase implementation.
Private Function StringComparer_Compare(x As Variant, y As Variant) As Long If VarType(x) = vbString Then If VarType(y) = vbString Then StringComparer_Compare = CorString.Compare(x, y, mComparisonType) Exit Function End If End If StringComparer_Compare = Comparer.Default.Compare(x, y) End Function