Fungsi VBScript FormatPercent
Fungsi FormatPercent mengembalikan ekspresi diformat sebagai persentase (dengan persentase% karakter tertinggal (dikalikan dengan 100)).
tatabahasa
FormatPercent(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
参数 | 描述 |
---|---|
expression | 必需。需被格式化的表达式。 |
NumDigAfterDec | 可选。指示小数点右侧显示位数的数值。默认值为 -1(使用的是计算机的区域设置)。 |
IncLeadingDig | 可选。指示是否显示小数值的前导零:
|
UseParForNegNum | 可选。指示是否将负值置于括号中:
|
GroupDig | 可选。指示是否使用计算机区域设置中指定的数字分组符号将数字分组:
|
contoh 1
'How many percent is 6 of 345?
document.write(FormatPercent(6/345))
Output:
1.74%
document.write(FormatPercent(6/345))
Output:
1.74%
contoh 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%
Lengkap VBScript Referensi