VBScript FormatCurrency 函数
定义和用法
FormatCurrency 函数可返回作为货币值被格式化的表达式,使用系统控制面板中定义的货币符号。
语法
FormatCurrency(Expression[,NumDigAfterDec[, IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
Parameters | Description |
---|---|
expression | Required. The expression 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:
¥20000.58