Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

VBScript FormatNumber Function

VBScript FormatNumber Function


VBScript reference manual 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
  • | | UseParForNegNum | Optional. Indicates whether to place negative values in parentheses: | | GroupDig | Optional. Indicates whether to group digits using the grouping symbol specified in the computer's regional settings: |

    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 »


    VBScript reference manual Complete VBScript Reference Manual