Function Coerce Make Class

CoerceToDouble

"Coerce String To Double" Return the Double value whose in-memory representation is the same as the first eight characters in string vString. Coerce an 8-character string value into a Double precision floating point value. Similar to casting a character string into a double value in the C language. Same as the CVD function in earlier versions of Microsoft Basic. Inverse of the MakeDouble (MKD) function.

Signature (Visual Basic / VBA)

Public Function CoerceToDouble( _
    ByVal vString As Variant _
    ) As Variant

Code Example

    CoerceToDouble(String$(8, 0)) = 0
    CoerceToDouble(String$(8, 1)) = 7.74860418548935E-304#
    CoerceToDouble(String$(8, 2)) = 5.37794075126812E-299#
    IsNull(CoerceToDouble(Null)) = True

Parameters

Parameter Description
vString The string whose first 8 (eight) characters are to be interpreted as a Double value. Function returns Null if vString is Null or cannot be fixed up to a String.

Notes & Version History

Note Function generates the Visual Basic Error "Illegal Function Call" if vString is less than 8 characters long (the size of a Double value).
Note If vString is more than eight characters long, the leftmost eight characters are coerced to a Double value.
Note This function first converts the string from Unicode to the default code page of the system.
v1.3 Change Removed 16-bit support from this function.