VBScript FormatPercent function
FormatPercent function returns an expression formatted as a percentage (with a trailing% character percentage (multiplied by 100)).
grammar
FormatPercent(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
参数 | 描述 |
---|---|
expression | 必需。需被格式化的表达式。 |
NumDigAfterDec | 可选。指示小数点右侧显示位数的数值。默认值为 -1(使用的是计算机的区域设置)。 |
IncLeadingDig | 可选。指示是否显示小数值的前导零:
|
UseParForNegNum | 可选。指示是否将负值置于括号中:
|
GroupDig | 可选。指示是否使用计算机区域设置中指定的数字分组符号将数字分组:
|
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