VBScript FormatPercent 函數

FormatPercent 函數返回作為百分數被格式化的運算式(尾隨有 % 符號的百分比(乘以 100 ))。
語法
FormatPercent(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
參數 | 描述 |
---|---|
expression | 必需。需被格式化的運算式。 |
NumDigAfterDec | 可選。指示小數點右側顯示位數的數值。默認值為 -1(使用的是電腦的區域設置)。 |
IncLeadingDig | 可選。指示是否顯示小數值的前導零:
|
UseParForNegNum | 可選。指示是否將負值置於括弧中:
|
GroupDig | 可選。指示是否使用電腦區域設置中指定的數字分組符號將數字分組:
|
實例 1
'How many percent is 6 of 345?
document.write(FormatPercent(6/345))
Output:
1.74%
document.write(FormatPercent(6/345))
Output:
1.74%
實例 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%
