WHex
Returns the hexadecimal `WString` (Unicode) representation of a number
Syntax
`
Declare Function WHex Overload ( ByVal number As Byte ) As WString
Declare Function WHex ( ByVal number As Byte, ByVal digits As Integer ) As WString
Declare Function WHex ( ByVal number As Short ) As WString
Declare Function WHex ( ByVal number As Short, ByVal digits As Integer ) As WString
Declare Function WHex ( ByVal number As Integer ) As WString
Declare Function WHex ( ByVal number As Integer, ByVal digits As Integer ) As WString
Declare Function WHex ( ByVal number As LongInt ) As WString
Declare Function WHex ( ByVal number As LongInt, ByVal digits As Integer ) 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 an `Integer, 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`