See Also: Locale Formatting Functions, String Functions, SetNumberFormat, SetCurrencyFormat, FormatNumber, FormatValue



The FormatCurrency function formats a number and returns it as a string. The formatting by default uses the locale currency settings of your machine, and the iPoints parameter determines the number of digits to the right of the decimal.

This can be used to format a string containing currency when not using a data entry object (DEO), such as dbForm or cWebForm.

Return Type



Use gFormatNumbers.pkg


(FormatCurrency( {nVar}, {iPoints} ))


0 or Greater

Use the points as specified to limit the digits to the right of the decimal


Uses points a defined by the local currency setting


Allow any number of points to the right of the decimal as needed


What it Does

The formatting of the fractional portion is based on the iPoints parameter value. The rest of the currency formatting uses your locale Regional Setting Properties for Currency.

If you do not wish to use these default currency settings you may customize a format-string to use as the formatting mask by sending the SetCurrencyFormat message.

Move (FormatCurrency(nVar, 2)) to sString

Formatting with the locale Regional Setting Properties for Currency will give different results since settings can be different on each computer.

For example:

Move (FormatCurrency(nNumber, 2)) to sString

Would result with DM123.222,22 and -DM123.222,22 with German settings, but $123,222.22 and -$123,222.22 with USA regional settings.


This example shows when to use the FormatCurrency and FormatNumber functions:

Procedure OnBody

    Send WriteHtmlRowBegin

        Send WriteHtmlCell (HtmlEncode(invt.Item_id)) 'align="left" '

        Send WriteHtmlCell (HtmlEncode(Invt.Description)) 'align="left" '

        Send WriteHtmlCell (FormatNumber(OrderDtl.Price,2)) 'align="right" '

        Send WriteHtmlCell (FormatNumber(OrderDtl.Qty_ordered,0)) 'align="right" '

        // displays extended price with currency symbol:

        Send WriteHtmlCell (FormatCurrency(OrderDtl.Extended_Price,2)) 'align="right" '

        Send AddSubTotal 1 OrderDtl.Extended_Price

    Send WriteHtmlRowEnd



Procedure OnPageBottom

    Number nTotal


    Send WriteHtmlCell "" 'colspan="4" bgColor="Silver" '

    Get SubTotal 1 to nTotal

    Send WriteHtmlCell (FormatCurrency(nTotal,2)) 'bgColor="Silver" align="right" '

    Send WriteHtmlTableEnd