YouTip LogoYouTip

Func Formatcurrency

# VBScript FormatCurrency Function * * Complete VBScript Reference Manual](#) * * * The FormatCurrency function returns an expression formatted as a currency value, using the currency symbol defined in the computer system control panel. ### Syntax FormatCurrency(Expression[,NumDigAfterDec[, IncLeadingDig[,UseParForNegNum[,GroupDig]]]]) | Parameter | Description | | :--- | :--- | | expression | Required. The expression to be formatted. | | NumDigAfterDec | Optional. Indicates the number of digits displayed to the right of the decimal point. The default value is -1 (uses the computer's regional settings). | | IncLeadingDig | Optional. Indicates whether to display leading zeros for decimal values: * -2 = TristateUseDefault - Uses the computer's regional settings * -1 = TristateTrue - True * 0 = TristateFalse - False | | UseParForNegNum | Optional. Indicates whether to place negative values in parentheses: * -2 = TristateUseDefault - Uses the computer's regional settings * -1 = TristateTrue - True * 0 = TristateFalse - False | | GroupDig | Optional. Indicates whether to group numbers using the digit grouping symbol specified in the computer's regional settings: * -2 = TristateUseDefault - Uses the computer's regional settings * -1 = TristateTrue - True * 0 = TristateFalse - False | ## Examples ## Example 1 document.write(FormatCurrency(20000)) The output of the above example: $20,000.00 [Try it Β»](#) ## Example 2 Set the number of digits after the decimal point: document.write(FormatCurrency(20000,2) & "
") document.write(FormatCurrency(20000,5)) The output of the above example: $20,000.00 $20,000.00000 [Try it Β»](#) ## Example 3 Whether to display leading zeros for decimal values: document.write(FormatCurrency(.20,,0) & "
") document.write(FormatCurrency(.20,,-1)) The output of the above example: $.20 $0.20 [Try it Β»](#) ## Example 4 Whether to place negative values in parentheses: document.write(FormatCurrency(-50,,,0) & "
") document.write(FormatCurrency(-50,,,-1)) The output of the above example: -$50.00 ($50.00) [Try it Β»](#) ## Example 5 Whether to group one million dollars: document.write(FormatCurrency(1000000,,,,0) & "
") document.write(FormatCurrency(1000000,,,,-1)) The output of the above example: $1000000.00 $1,000,000.00 [Try it Β»](#) * * Complete VBScript Reference Manual](#)
← Func FormatnumberFunc Oct β†’