Returns a formatted String version of the supplied amount value, according to the specified formatting parameters.
All aspects of the formatting are configurable so that monetary values can be displayed in just about any currency, whether it be pounds and pence, dollars and cents, deutschmarks and pfennigs, Japanese yen or Korean won. Currency symbol prefixes and suffixes, negative values and thousands separators are all supported. See the working example below for a demonstration.
strMoney = FormatMoney( amount, currency_symbol_before, currency_symbol_after, thousands_separator, decimal_point, significant_after_decimal_pt, display_after_decimal_pt )
amount The value to be formatted. Usually amount is a numeric value but a String can be supplied, since parseFloat(…) is used to check the incoming value. currency_symbol_before Currency symbol/text string to be placed before the amount (and after any − sign) currency_symbol_after Currency symbol/text string appended to the amount. thousands_separator Thousands separator string to apply for amounts ≥ 1000. decimal_point Decimal point (period) string to apply if required. significant_after_decimal_pt Number of significant digits after the decimal point. display_after_decimal_pt Number of digits to display after the decimal point. (Must be ≥ 0)
Returns a String containing the formatted amount, or a String with the digits replaced by hash marks (#) if the formatted value contained too many digits.
Just about any currency can be easily supported by changing the appropriate parameters. By pressing the Calculate button in the example below you'll get a good idea of how these parameters affect the outcome.
|Price per kg/item||Quantity (kg/items)||Actual value|
|currency symbol before||currency symbol after||thousands separator||decimal point||significant after decimal pt||display after decimal pt||FormatMoney()|
The following are links to external sites discovered during Google searches:
This document and the software contained herein are covered by the MIT License; see the license page for more information.