VBScript FormatNumber Function
Complete VBScript Reference Manual
The FormatNumber function returns an expression formatted as a number.
Syntax
FormatNumber(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
| Parameters | Description |
|---|---|
| expression | Required. The expression to be formatted. |
| NumDigAfterDec | Optional. A numeric value indicating the number of digits displayed to the right of the decimal point. The default is -1 (using the computer's regional settings). |
| IncLeadingDig | Optional. Indicates whether to display leading zeros for decimal values:
|
- -2 = TristateUseDefault - Uses the computer's regional settings
- -1 = TristateTrue - True
- 0 = TristateFalse - False
- -2 = TristateUseDefault - Uses the computer's regional settings
- -1 = TristateTrue - True
- 0 = TristateFalse - False
Example
Example 1
The example above produces the following output:
20,000.00
Try it »
Example 2
Set the number of digits after the decimal point:
The example above produces the following output:
20,000.00
20,000.00000
Try it »
Example 3
Whether to display leading zeros for decimal values:
The example above produces the following output:
.20
0.20
Try it »
Example 4
Whether to place negative values in parentheses:
The example above produces the following output:
-50.00
(50.00)
Try it »
Example 5
Whether to group numbers:
The example above produces the following output:
1000000.00
1,000,000.00
Try it »
Complete VBScript Reference Manual