FormatNumber

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

 

Purpose

The FormatNumber function formats a number and returns it as a string. The formatting by default uses the locale number 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 numbers when not using a data entry object (DEO), such as dbForm or cWebForm.

Return Type

String

Syntax

Use gFormatNumbers.pkg

 

(FormatNumber( {nVar}, {iPoints} ))

Where:

0 or Greater

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

-1

Use points as defined in the SetNumberFormat message

-2

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 number formatting uses your locale Regional Setting Properties for Numbers.

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 SetNumberFormat message.

Move (FormatNumber(nVar, 2)) to sString

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

For example:

Move (FormatNumber(nNumber, 2)) to sString

Would result with 123.222,22 and -123.222,22 with German settings, but 123,222.22 and -123,222.22 with USA regional settings.

Special Notes