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

Coerce To Integer Function
Coerce Make Class

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

"Coerce String To Integer"
Return the Integer value whose in-memory representation is the same as the first two characters in string vString.
Same as the CVI function in earlier versions of Microsoft Basic.
Inverse of the MakeInteger (MKI) function.

Examples:
    CoerceToInteger(Chr$(0) + Chr$(0)) = 0%
    CoerceToInteger(Chr$(1) + Chr$(0)) = 1%
    CoerceToInteger(Chr$(0) + Chr$(1)) = 256%
    CoerceToInteger(Chr$(255) + Chr$(255)) = -1%
    IsNull(CoerceToInteger(Null)) = True
See also:
    CoerceToIntegerFast Function
    MakeInteger Function
    CoerceToVarType Function
    CoerceToLong Function
vString: The string whose first two characters are to be interpreted as an Integer value. Function returns Null if vString is Null or cannot be fixed up to a String.

Note: Function generates the Visual Basic Error "Illegal Function Call" if vString is less than 2 characters long (the size of an Integer value).
Note: If vString is more than two characters long, the leftmost two characters are coerced to an Integer 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.

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