Function Coerce Make Class

CoerceToByte

"Coerce String To Byte" Return the Byte value whose in-memory representation is the same as the first character in string vString. Inverse of the MakeByte function.

Signature (Visual Basic / VBA)

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

Code Example

    CoerceToByte(Chr$(0)) = 0
    CoerceToByte(Chr$(1)) = 1
    CoerceToByte(Chr$(255)) = 255
    IsNull(CoerceToByte(Null)) = True

Parameters

Parameter Description
vString The string whose first character is to be interpreted as a Byte 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 an empty string.
Note If vString if more than one character long, the only the first character is used.