Function Convert Values Class

PromoteToMostCapableDataType

Possibly promotes one of two arguments to the more CAPABLE data type. The most capable data type is the one which has the widest range of values and is capable of representing both arguments.

Signature (Visual Basic / VBA)

Public Function PromoteToMostCapableDataType( _
      ByRef rOne As Variant _
    , ByRef rTwo As Variant _
    ) As Boolean

Code Example

    Assuming
       Dim varOne As Variant
       Dim varTwo As Variant
       varOne = 1%
       varTwo = 3#
    for example
       PromoteToMostCapableDataType(varOne, varTwo) = True
    leaves
       VarType(varOne) = vbDouble

Parameters

Parameter Description
rOne First of the two values which may be promoted to a more capable data type. Note: This argument is pass-by-reference and it may be modified.
rTwo Second of the two values which may be promoted to a more capable data type. Note: This argument is pass-by-reference and it may be modified. This function uses the MostCapableDataType function to determine the data type to which arguments will be promoted.

Notes & Version History

Details The data type of one or both arguments will be changed so that they are capable of storing the same type of values. Function returns True upon success, but may generate an error if passed arguments such as object pointers.