ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods






FUNCTION:  FormatCurrency( )

FormatCurrency(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigit)

The FormatCurrency function return a formatted currency value for the numeric expression.


There is one mandatory argument.

Expression

The Expression argument is the number to be converted to a currency format.

Code:
< =FormatCurrency(31567) %>

Output:
$31,567.00

Note that this function rounds off values.

Code:
< =FormatCurrency(31567.8977) %>

Output:
$31,567.90


There are 4 optional arguments.


NumDigitsAfterDecimal
The optional NumDigitsAfterDecimal argument allows you to choose the number of digits after the decimal.

Code:
< =FormatCurrency(31567, 2) %>

Output:
$31,567.00


IncludeLeadingDigit
The optional IncludeLeadingDigit argument includes the leading zero.

You must only use the constant or value from the TRISTATE CONSTANTS for this argument.

CONSTANTVALUEDESCRIPTION
TRISTATETrue-1True, will use options
TRISTATEFalse 0False, will not use options
TRISTATEUSEDEFAULT-2Use default setting

Code:
< =FormatCurrency(.77, 2, -1) %>

Output:
$0.77


UseParensForNegativeNumbers
The optional UseParensForNegativeNumber argument replaces a negative sign with parentheses around the number.

You must only use the constant or value from the TRISTATE CONSTANTS for this argument.

CONSTANTVALUEDESCRIPTION
TRISTATETrue-1True, will use options
TRISTATEFalse 0False, will not use options
TRISTATEUSEDEFAULT-2Use default setting

Code:
< =FormatCurrency(-31567, 2, 0, -1) %>

Output:
($31,567.00)


GroupDigit
The optional GroupDigit argument allows the use of the options specified in the Currency tab in the Regional Settings Properties in the Control Panel.

You must only use the constant or value from the TRISTATE CONSTANTS for this argument.

CONSTANTVALUEDESCRIPTION
TRISTATETrue-1True, will use options
TRISTATEFalse 0False, will not use options
TRISTATEUSEDEFAULT-2Use default setting

Code:
< =FormatCurrency(31567, 2, 0, -1, -1) %>

Output:
$31,567.00