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

Coerce To Var Type Function
Coerce Make Class

Public Function CoerceToVarType( _
      ByVal vString As Variant _
    , ByVal vVarType As Variant _
    ) As Variant

"Coerce String To Value Of Type"
Return the value whose in-memory representation is the same as the corresponding characters in string vString.
Applies the appropriate CoerceTo function depending upon the VarType Constant in vVarType.

Examples:
    CoerceToVarType(Chr$(1) + Chr$(1), vbInteger) = 257%
    CoerceToVarType(Chr$(1) + Chr$(1) + Chr$(0) + Chr$(0), vbLong) = 257&
    CoerceToVarType(Chr$(1) + Chr$(1), vbInteger) = CoerceToInteger(Chr$(1) + Chr$(1))
See also:
    MakeVarType Function
    CoerceToBoolean Function
    CoerceToByte Function
    CoerceToCurrency Function
    CoerceToDate Function
    CoerceToDouble Function
    CoerceToInteger Function
    CoerceToLong Function
    CoerceToSingle Function
vString: The string whose leading characters are to be interpreted as the data type identified by vVarType.
vVarType: The data type to which the string vString will be coerced. Function returns Null if vVarType is Null or cannot be fixed up to a number.

Note: Function generates the Visual Basic Error "Illegal Function Call" if vString is shorter than the data type to which it is being coerced.
Note: Function uses the leftmost characters in vString when it is longer than target data type.
Note: This function first converts the string from Unicode to the default code page of the system (in most cases except for that of the Coercion to a Byte).

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