Description
The FormatNumber() function returns an expression formatted as a number.
This function has the form:
FormatNumber(expression [,NumDigAfterDec [,IncLeadingDig [,UseParForNegNum [,GroupDig]]]])
Parameter | Description |
---|---|
expression | (required) The expression to be formatted |
NumDigAfterDec | (optional) Indicates how many places to the right of the decimal are displayed. Default is -1 (the computer's regional settings are used) |
IncLeadingDig | (optional) Indicates whether or not a leading zero is
displayed for fractional values:
|
UseParFor NegNum |
(optional) Indicates whether or not to place negative
values within parentheses:
|
GroupDig | (optional) Indicates whether or not numbers are grouped
using the group delimiter specified in the computer's regional settings:
|
Examples
The following examples show the basic use of this function:
Example 1
Msgbox(FormatNumber(20000))
This produces the following result:
20,000.00
Example 2
Setting number of decimals:
Msgbox(FormatNumber(20000,2))
Msgbox(FormatNumber(20000,5))
This produces the following result (each line in a separate pop-up message box):
20,000.00
20,000.00000
Example 3
Fractional values with or without a leading zero:
Msgbox(FormatNumber(.20,,0))
Msgbox(FormatNumber(.20,,-1))
This produces the following result (each line in a separate pop-up message box):
.20
0.20
Example 4
Negative values inside parentheses or not:
Msgbox(FormatNumber(-50,,,0))
Msgbox(FormatNumber(-50,,,-1))
This produces the following result (each line in a separate pop-up message box):
-50.00
(50.00)
Example 5
Grouping numbers - or not:
Msgbox(FormatNumber(1000000,,,,0))
Msgbox(FormatNumber(1000000,,,,-1))
This produces the following result (each line in a separate pop-up message box):
1000000.00
1,000,000.00
Miscellaneous Information
Supported in Version: | 2.0 |
---|