<-- Previous || Up || Next -->

Fix Up Variant To Boolean Maybe Sub Sub
Fix Ups Class

Public Sub FixUpVariantToBooleanMaybeSub( _
      ByRef rArgument As Variant _
    , ByVal vDefault As Variant _

"Fix Up Variant To Boolean Maybe Subroutine"
Assign the value vDefault to rArgument if rArgument cannot be converted to a Boolean value.
Numeric strings are converted into Boolean values,
date/time strings are converted into Date values,
and other numeric values are left as-is.

See also:
    FixUpVariantToBooleanMandSub Subroutine
    FixUpVariantToBooleanMaybeFn Function
rArgument: Argument that is checked for compatibility with the Boolean data type. Argument will actually be converted to a Boolean value if it is a numeric string or date/time string. Subroutine assigns the default value vDefault to rArgument if conversion is not possible, such as when the rArgument is out-of-range, missing, Null, an error, a pointer, or a non-numeric string.
Note: rArgument is a passed by reference, so the variable passed from the calling function may be modified.
vDefault: The default value which is assigned to rArgument when conversion is not possible.
Note: The default value can be a data type other than Boolean as long as it is compatible with the variable passed via rArgument.

Example #1:

       Dim varFlag As Variant
       varFlag = "0"
    for example
       FixUpVariantToBooleanMaybeSub varFlag, True
       varFlag = False
       VarType(varFlag) = vbBoolean
Example #2:
       Dim varFlag2 As Variant
       varFlag2 = 0
    for example
       FixUpVariantToBooleanMaybeSub varFlag2, True
       varFlag2 = 0
       VarType(varFlag2) = vbInteger
Example #3:
       Dim varFlag3 As Variant
       varFlag3 = "Word"
    for example
       FixUpVariantToBooleanMandSub varFlag3, True
       varFlag3 = True
       varType(varFlag3) = vbBoolean

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.