FormatLong (Convert a Long Value)

The FormatLong function is used to convert a Long value to a decimal, hexadecimal, or octal string.

Consider using Sprintf rather than FormatLong, which provides greater flexibility and functionality.

Syntax

Variable = FormatLong ( LongVar, FormatString )

Remarks

FormatLong can be used to store a formatted Long into a string, or it can be used within another instruction to format a Long.

Parameters

LongVar (Long Variable)

The variable that will be formatted.

Type: Long variable

FormatString (Format String)

A code used to apply formatting to the Long variable. Options are:

Code Description
%d Signed decimal integer (same as i)
%i Signed decimal integer (same as d)
%u Unsigned decimal integer
%x Hexadecimal integer, lower case
%X Hexadecimal integer, upper case
%o Octal (base 8)
%b Binary (base 2)

Type: Variable

The formatted Long can be padded with zeros (or spaces), using the notation %#code (right justified) or %-#code (left justified), where # is the number of spaces for the field.

Consider the following examples, where the Long variable is 12345.

Note that multiple format specifiers are not allowed.