# Description

The FormatNumber() function returns an expression formatted as a number.

This function has the form:

``FormatNumber(expression [,NumDigAfterDec [,IncLeadingDig [,UseParForNegNum [,GroupDig]]]])``

Parameter Description
expression (required) The expression to be formatted
NumDigAfterDec (optional) Indicates how many places to the right of the decimal are displayed. Default is -1 (the computer's regional settings are used)
IncLeadingDig (optional) Indicates whether or not a leading zero is displayed for fractional values:
• -2 = TristateUseDefault - Use the computer's regional settings
• -1 = TristateTrue - True
• 0 = TristateFalse - False
UseParFor
NegNum
(optional) Indicates whether or not to place negative values within parentheses:
• -2 = TristateUseDefault - Use the computer's regional settings
• -1 = TristateTrue - True
• 0 = TristateFalse - False
GroupDig (optional) Indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings:
• -2 = TristateUseDefault - Use the computer's regional settings
• -1 = TristateTrue - True
• 0 = TristateFalse - False

# Examples

The following examples show the basic use of this function:

## Example 1

``````Msgbox(FormatNumber(20000))
``````

This produces the following result:

``` 20,000.00```

## Example 2

Setting number of decimals:

``````Msgbox(FormatNumber(20000,2))
Msgbox(FormatNumber(20000,5))
``````

This produces the following result (each line in a separate pop-up message box):

``` 20,000.00 20,000.00000 ```

## Example 3

Fractional values with or without a leading zero:

``````Msgbox(FormatNumber(.20,,0))
Msgbox(FormatNumber(.20,,-1))
``````

This produces the following result (each line in a separate pop-up message box):

``` .20 0.20 ```

## Example 4

Negative values inside parentheses or not:

``````Msgbox(FormatNumber(-50,,,0))
Msgbox(FormatNumber(-50,,,-1))
``````

This produces the following result (each line in a separate pop-up message box):

``` -50.00 (50.00)```

## Example 5

Grouping numbers - or not:

``````Msgbox(FormatNumber(1000000,,,,0))
Msgbox(FormatNumber(1000000,,,,-1))
``````

This produces the following result (each line in a separate pop-up message box):

``` 1000000.00 1,000,000.00```

# Miscellaneous Information

 Supported in Version: 2

Content