FormatCurrency Function

Tips >>ASP Functions


WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE

The FormatCurrency function returns an expression formatted as a currency value using the currency symbol defined in the computer's control panel. The FormatCurrency function return a formatted currency value for the numeric expression.

The Syntax of the formatcurrency function is :-

Format Currency (Expression[,NumDigAfterDec[, IncLeadingDig[,UseParForNegNum[,GroupDig]]]])

Example#1 :-

Code :-
document.write(FormatCurrency(20000))
Output :-

$20,000.00

Example#2 :-

Code :-
document.write(FormatCurrency(20000.578,2))
Output :-
$20,000.58

Example#3 :-

Code :-
document.write(FormatCurrency(20000.578,2,,,0))
Output :-
$20000.58

Example#4 :-

Code :-
<% =FormatCurrency(31567) %>
Output :-
$31,567.00

Example#5 :-

Code :-
<% =FormatCurrency(31567.8977) %>
Output :-
$31,567.90

Note :- These function rounds off the values. If number written after decimal is less than 5 nothing is written after decimal. If number written after the decimal is more than 5 the round off value is written.

There are four types of Format Currency :-

  1. Num Digits After Decimal :- The optional Num Digits After Decimal argument allows you to choose the number of digits after the decimal.

    Example#1 :-

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

    $31,567.00

  2. Include Leading Digit :- The optional Include Leading Digit argument includes the leading zero.

    Example#1 :-

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

  3. Use Parens For Negative Numbers :- The optional Use Parens For Negative Number argument replaces a negative sign with parentheses around the number.

    Example#1 :-

    Code :-
    <% =FormatCurrency(-31567, 2, 0, -1) %>
    Output :-
    $31,567.00

  4. Group Digit :- The optional Group Digit argument allows the use of the options specified in the Currency tab in the Regional Settings Properties in the Control Panel.

    Example#1 :-

    Code :-
    <% =FormatCurrency(31567, 2, 0, -1, -1)
    Output :-
    $31,567.00
 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

Whatsapp Icon +91-9967648641

Whatsapp Icon +91-9967648641