Description
The FormatCurrency function returns an expression formatted as a currency value using the currency symbol defined in the computer's control panel.
This function has the form:
FormatCurrency(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(FormatCurrency(20000))
This produces the following result:
$20,000.00
Example 2
Setting number of decimals:
Msgbox(FormatCurrency(20000,2))
Msgbox(FormatCurrency(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(FormatCurrency(.20,,0))
Msgbox(FormatCurrency(.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(FormatCurrency(-50,,,0))
Msgbox(FormatCurrency(-50,,,-1))
This produces the following result (each line in a separate pop-up message box):
-$50.00
($50.00)
Example 5
Grouping a million dollars - or not:
Msgbox(FormatCurrency(1000000,,,,0))
Msgbox(FormatCurrency(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 |
---|