VBScript FormatPercent Function
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
- -2 = TristateUseDefault - Uses the computer's regional settings
- -1 = TristateTrue - True
- 0 = TristateFalse - False
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%
Complete VBScript Reference Manual