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

VBScript FormatPercent Function

VBScript FormatPercent Function


VBScript reference manual Complete VBScript Reference Manual


The FormatPercent function returns an expression formatted as a percentage (multiplied by 100, with a trailing % sign).

Syntax

FormatPercent(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 1

    'How many percent is 6 of 345?

    document.write(FormatPercent(6/345))

    Output:

    1.74%

    Example 2

    'How many percent is 6 of 345?

    document.write(FormatPercent(6/345,1))

    Output:

    1.7%


    VBScript reference manual Complete VBScript Reference Manual