当前位置: 首页 > 图文教程 > 脚本技术 > VBScript > VBS教程:函数-FormatNumber 函数

VBScript
VBS教程:函数-LoadPicture 函数
VBS教程:函数-Len 函数
VBS教程:函数-Left 函数
VBS教程:函数-LCase 函数
VBS教程:函数-LBound 函数
VBS教程:函数-Join 函数
VBS教程:函数-IsObject 函数
VBS教程:函数-IsNumeric 函数
VBS教程:函数-IsNull 函数
VBS教程:函数-IsEmpty 函数
VBS教程:函数-IsDate 函数
VBS教程:函数-IsArray 函数
VBS教程:函数-Int、Fix 函数
VBS教程:函数-InStrRev 函数
VBS教程:函数-InStr 函数
VBS教程:函数-InputBox 函数
VBS教程:函数-Hour 函数
VBS教程:函数-Hex 函数
VBS教程:函数-GetRef 函数
VBS教程:函数-GetObject 函数

VBScript 中的 VBS教程:函数-FormatNumber 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 90 ::
收藏到网摘: n/a

FormatNumber 函数

返回表达式,此表达式已被格式化为数值。

FormatNumber(
expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]]
)

Arguments

Expression

必选项。要被格式化的表达式。

NumDigitsAfterDecimal

可选项。指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。

IncludeLeadingDigit

可选项。三态常数,指示是否显示小数值小数点前面的零。有关数值,请参阅“设置”部分。

UseParensForNegativeNumbers

可选项。三态常数,指示是否将负值置于括号中。有关数值,请参阅“设置”部分。

GroupDigits

可选项。三态常数,指示是否使用计算机区域设置中指定的数字分组符号将数字分组。有关数值,请参阅“设置”部分。

设置

IncludeLeadingDigit、UseParensForNegativeNumbers 和 GroupDigits 参数可以有以下值:

常数描述
TristateTrue-1True
TristateFalse0False
TristateUseDefault-2使用计算机区域设置中的设置。

说明

当省略一个或多个可选项参数时,由计算机区域设置提供被省略参数的值。

注意 所有设置信息均取自区域设置的“数字”附签。

下面例子利用 FormatNumber 函数把数值格式化为带四位小数点的数:

 Function FormatNumberDemo Dim MyAngle, MySecant, MyNumber MyAngle = 1.3 ' 用弧度定义角。 MySecant = 1 / Cos(MyAngle) ' 计算正割值。 FormatNumberDemo = FormatNumber(MySecant,4) '  MySecant 格式化为带四位小数点的数。End Function