VBScript FormatCurrency Function
Definition and Usage
The FormatCurrency function can return an expression formatted as a currency value, using the currency symbol defined in the system control panel.
Syntax
FormatCurrency(Expression[,NumDigAfterDec[, IncLeadingDig[UseParForNegNum[GroupDig]])
Parameters | Description |
---|---|
expression | Required. The expression that needs to be formatted. |
NumDigAfterDec | Indicates the number of digits to display to the right of the decimal point. The default value is -1 (using the computer's regional settings). |
IncLeadingDig | Optional. Indicates whether to display leading zeros (leading zero) for decimal values:
|
UseParForNegNum | Optional. Indicates whether to place negative values in parentheses.
|
GroupDig | Optional. Indicates whether to use the number grouping symbol specified in the computer's regional settings to group numbers.
|
Instance
Example 1
document.write(FormatCurrency(20000))
Output:
¥20,000.00
Example 2
document.write(FormatCurrency(20000.578,2))
Output:
¥20,000.58
Example 3
document.write(FormatCurrency(20000.578,2,,,0))
Output:
¥20,000.58