Function Windows API Class

CoerceIntegerToBoolean

Coerce an Integer value into a Boolean value. Return the Boolean value whose bytes have the same in-memory representation as the Integer value vValue.

Signature (Visual Basic / VBA)

Public Function CoerceIntegerToBoolean( _
    ByVal vValue As Integer _
    ) As Boolean

Code Example

    CoerceIntegerToBoolean(-1) = True
    CoerceIntegerToBoolean(0) = False
    CoerceIntegerToBoolean(1) = True
    CoerceIntegerToBoolean(56) = True

Notes & Version History

Note Since Boolean value are not capable of representing the same range of values as Integers, CoerceBooleanToInteger (CoerceIntegerToBoolean(X)) will likely not equal X.
Note We are not sure if this function has any use, but we included it to be consistent and complete.