Skip to content
Paul Squires edited this page Oct 19, 2026 · 2 revisions

Home › String Functions › WHex

WHex

Returns a number as hexadecimal wide-string text.

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

Parameters

  • number
  • digits

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)

Return Value

Returns a hexadecimal WString representation of number, truncated or padded with zeros ("0") to fit the number of digits, if specified.

Remarks

Usage

result = WHex( number [, digits ] )

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

Examples

Print Hex(54321)

Print Hex(54321, 2)

Print Hex(54321, 5)

will produce the output:

D431
31
0D431

Category: String Functions
Kind: function


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally