VBScript FormatPercentFunction
Complete VBScript Reference
The FormatPercent function returns an expression formatted as a percentage (multiplied by 100) with a trailing % symbol.
Syntax
FormatPercent(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
| Parameters | Description |
|---|---|
| expression | Required. Expression to be formatted. |
| NumDigAfterDec | Optional. A value indicating how many digits are displayed to the right of the decimal point. Default value is -1 (uses the computer's regional settings). |
| IncLeadingDig | Optional. Indicates whether a leading zero is displayed for fractional values:
|
| UseParForNegNum | Optional. Indicates whether negative values are placed in parentheses:
|
| GroupDig | Optional. Indicates whether numbers are grouped using the digit 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%
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%
document.write(FormatPercent(6/345,1))
Output:
1.7%
Complete VBScript Reference Other Extensions