FormatNumber(expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])
IncludeLeadingDigit、UseParensForNegativeNumbers 和 GroupDigits 参数可以有以下值:
| 常数 | 值 | 描述 |
|---|---|---|
| TristateTrue | -1 | True |
| TristateFalse | 0 | False |
| TristateUseDefault | -2 | 使用计算机区域设置中的设置。 |
当省略一个或多个可选项参数时,由计算机区域设置提供被省略参数的值。
注意 所有设置信息均取自区域设置的“数字”附签。
下面例子利用 FormatNumber 函数把数值格式化为带四位小数点的数:
Function FormatNumberDemoDim MyAngle, MySecant, MyNumberMyAngle = 1.3 ' 用弧度定义角。MySecant = 1 / Cos(MyAngle) ' 计算正割值。FormatNumberDemo =FormatNumber(MySecant,4)' 把 MySecant 格式化为带四位小数点的数。End Function