Function Comparisons Class

EqualLikeDataType

Return True if the values vOne and vTwo equal each other, otherwise return False. Compares values with similar data types, but never considers strings equal to numbers.

Signature (Visual Basic / VBA)

Public Function EqualLikeDataType( _
      ByVal vOne As Variant _
    , ByVal vTwo As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Boolean

Code Examples

    EqualLikeDataType("ALL", "all", vbBinaryCompare) = False
    EqualLikeDataType("all", "ALL", vbBinaryCompare) = False
    EqualLikeDataType("ALL", "all", vbTextCompare) = True
    EqualLikeDataType("3", 3) = False
    EqualLikeDataType(Null, 3) = False
    True  if vOne =  vTwo
    False if vOne <> vTwo
    Null = Null -> True
    Null = Not Null -> False
    Empty = Empty -> True
    Empty = Not Empty -> False
    Number/Date = Number/Date -> Use numeric comparison.
    Number/Date = String -> False
    String = String -> Use string comparison.
             vTwo
           E N D S
    vOne E T F F F
         N F T F F
         D F F n F
         S F F F s
    E = Empty
    N = Null
    D = Date/Numeric
    S = String
    T = Return True
    F = Return False
    s = Do String comparison with StrComp
    n = Do numeric/Date comparison

Parameters

Parameter Description
vOne First of two values which are to be compared for equality.
vTwo Second of two values which are to be compared for equality.
vCompare Specifies the comparison type and sort order/collating sequence used when performing string comparisons. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number.

Notes & Version History

Function returns See the following table which describes how comparisons are made depending upon data type of arguments. Similar to the EqualCoerceDataType function, except that one fixes-up numeric values to strings if the other argument is a string.