Function Comparisons Class

StrCompCustom

"String Compare Custom" Like the Visual Basic StrComp function, except that it uses a custom sort order/collating sequence. Compare two string values to determine if one is less than, equal to, or greater than the other.

Signature (Visual Basic / VBA)

Public Function StrCompCustom( _
      ByVal vStringOne As Variant _
    , ByVal vStringTwo As Variant _
    , Optional ByVal vSortOrder As Variant _
    ) As Variant

Code Example

    StrCompCustom("S", "T", EveryCharacter) = -1
    StrCompCustom("S", "s", EveryCharacter) = -1
    StrCompCustom("s", "S", EveryCharacter) = 1

Parameters

Parameter Description
vStringOne First of two string values which are to be compared to determine if it is less than, equal to, or greater than the other. Function returns Null if vStringOne is Null or cannot be fixed up to a String.
vStringTwo Seconds of two string values which are to be compared to determine if it is less than, equal to, or greater than the other. Function returns Null if vStringTwo is Null or cannot be fixed up to a String.
vSortOrder String whose characters define the custom sort order/collating sequence that will be used to compare the two strings vStringOne and vStringTwo. vSortOrder defaults to the value of the EveryCharacter function if it is missing or Null or cannot be fixed up to a String; with vSortOrder set to that string, it will perform Binary comparisons and would be the same as calling the StrComp function with an Compare argument of vbBinaryCompare. The Asc(ii) values in the SortOrder string represent the collating sequence of the character at that position + 1. For example, the Asc(ii) value of Left$(vSortOrder, 1) represents the collating sequence of Chr$(0), Asc(Mid$(vSortOrder, 2, 1)) represents the collating sequence of Chr$(1), etc.