WHex
Returns the hexadecimal `WString` (Unicode) representation of a number
Syntax
`
Declare Function WHex ( ByVal number As UByte ) As WString
Declare Function WHex ( ByVal number As UShort ) As WString
Declare Function WHex ( ByVal number As Ulong ) As WString
Declare Function WHex ( ByVal number As ULongInt ) As WString
Declare Function WHex ( ByVal number As Const Any Ptr ) As WString
Declare Function WHex ( ByVal number As UByte, ByVal digits As Long ) As WString
Declare Function WHex ( ByVal number As UShort, ByVal digits As Long ) As WString
Declare Function WHex ( ByVal number As Ulong, ByVal digits As Long ) As WString
Declare Function WHex ( ByVal number As ULongInt, ByVal digits As Long ) As WString
Declare Function WHex ( ByVal number As Const Any Ptr, ByVal digits As Long ) As WString
`
Usage
`
result = WHex( number [, digits ] )
`
Parameters
`number`
A whole number or expression evaluating to a whole number.
`digits`
Optional number of digits to return.
Return Value
Returns a hexadecimal `WString` representation of `number`, truncated or padded with zeros (`"0"`) to fit the number of digits, if specified.
Description
Hexadecimal digits range from `0`-`9`, or `A`-`F`.
If you specify `digits` > `0`, the resulting `WString` will be exactly that length. It will be truncated or padded with zeros on the left, if necessary.
The length of the wstring will not go longer than the maximum number of digits required for the type of `expression` (8 for a `Long`, 16 for floating point or `LongInt`)
Example
`
Print Hex(54321)
Print Hex(54321, 2)
Print Hex(54321, 5)
`
will produce the output:

    D431
    31
    0D431

Platform Differences

- Unicode strings are not supported in the DOS port of FreeBASIC.

Dialect Differences

- Not available in the -lang qb dialect unless referenced with the alias `__Whex`.

Differences from QB

- New to FreeBASIC.

See also

- `Hex`
- `WBin`
- `WOct`