Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Numeric Expression Formats
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Numeric Expression Formats
■ Default settings for date and time formats are determined by the operating
system. See: ◄Date and Time Command Summary►
■ Visual Basic supports international formatting styles under MS-DOS
version 3.31 or later. See: ◄FORMAT$ Function►
■ You can use the following symbols to create the format expression used
with FORMAT$:
Value Description
═══════════════ ════════════════════════════════════════════════
Null string General format (no formatting)
0 Digit placeholder
• If the number has fewer digits than there are
zeros (on either side of the decimal) in the
format expression, leading or trailing zeros
are displayed.
• If the number has more digits to the right of
the decimal point than there are zeros to the
right of the decimal in the format expression,
the number is rounded to as many decimal places
as there are zeros.
• If the number has more digits to the left of
the decimal point than there are zeros to the
left in the format expression, the extra digits
are displayed.
# Digit placeholder
• Follows the same rules as for the 0 digit
placeholder, except that extra zeros are not
displayed if the number has fewer digits on
either side of the decimal point than there
are #'s on either side of the format.
. Decimal point
• This symbol determines how many digits (#'s or
0's) display to the right and left of the
decimal point. Note: Some international
settings may cause the comma to be used
as a decimal point rather than a period.
• If the format contains only #'s to the left
of this symbol, then numbers smaller than 1
are begun with a decimal point. To avoid this,
you should use 0 as the first digit placeholder
to the left of a decimal point instead of #.
% Percentage
• The expression is multiplied by 100 and the
% character is inserted.
, Thousands separator
• Visual Basic separates thousands by commas (or
by periods if the country code has been set to
a country other than the United States) if the
format contains a comma surrounded by #'s or
0's.
• Two adjacent commas, or a comma immediately to
the left of the decimal point location (whether
there is a decimal specified or not) means
"Omit the three digits that fall between these
commas, or between the comma and the decimal
point, rounding as needed." Large numbers can
be scaled using this technique. For example,
the format string "##0,,." can be used to
represent 100 million, as simple 100. Numbers
smaller than 1 million are displayed as 0.
E- E+ e- e+ Scientific format
• If a format contains one digit placeholder
(0 or #) to the right of an E-, E+, e-, or e+,
Visual Basic displays the number in scientific
format and inserts an E or e between the number
and its exponent.
• The number of 0's or #'s to the right
determines the number of digits in the
exponent.
• Use E- or e- to place a minus sign next to
negative exponents. Use a E+ or e+ to place a
minus sign next to negative exponents and a
plus sign next to positive exponents.
: • + $ () space Display literal character
• To display a character other than one of these,
precede the character with a backslash (\) or
enclose the character(s) in double quotation
marks ("").
\ Display next character in format string
• Many characters in the format string have a
special meaning and cannot be displayed as
literal characters unless they are preceded
by a backslash. The backslash is not
displayed. This is the same as enclosing the
next character in double quotation marks.
• Examples of such characters are the date-
and time-formatting characters (y, m, d, h,
s, a, and p) and the numeric-formatting
characters (#, 0, %, E, e, comma, and
period).
"abc" Display text inside double quotes
• To include a text string in fmt$, you must
use CHR$(34) to enclose the text (34 is the
ASCII code for double quotation mark).
: Time separator
• The time separator is used to separate hours,
minutes, and seconds when time values are
formatted.
/ Date separator
• The date separator is used to separate day,
month, and year when date values are formatted.
See: ◄Sample Numeric Formats► ◄Format Specifiers►