Function Math Reals Class

Max2Variant

" Maximum Of Two Variant Values" Return the maximum of two values. Returns argument on left (vX) if arguments are equal.

Signature (Visual Basic / VBA)

Public Function Max2Variant( _
      ByVal vX As Variant _
    , ByVal vY As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    Max2Variant(23, 45) = 45
    Max2Variant(-12, 4) = 4
    Max2Variant(2%, 2#) = 2%
    Max2Variant(2#, 2%) = 2#
    Max2Variant("SA", "RO") = "SA"
    Max2Variant("SA", "ro") = "ro"
    Max2Variant("SA", "ro", vbTextCompare) = "SA"

Parameters

Parameter Description
vX First of two values, the maximum of which will be returned.
vY Second of two values, the maximum of which will be returned.
vCompare specifies the type of string comparison used to determine if strings match. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number.

Notes & Version History

Note Arguments are compared using the CompareLikeDataType function; see it for more details of how arguments are fixed up and comparisons are performed.
Note This function does not support three-valued logic because of the way that the CompareLikeDataType function treats Null values.