当前位置: 首页 > 网络学院 > 客户端脚本教程 > VBScript > VBScript FormatNumber 函数

VBScript
VBScript 介绍
如何使用 VBScript
VBScript 放置
VBScript 变量
VBScript 程序
VBScript 条件语句
VBScript 循环声明
VBScript 摘要
VBScript 实例
VBScript 函数
VBScript 关键字

VBScript FormatNumber 函数


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

The FormatNumber function returns an expression formatted as a number.
FormatNumber 函数可返回表达式,此表达式已被格式化为数值

语法

FormatNumber(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])

参数 描述
expression Required. The expression to be formatted
必选项。要被格式化的表达式
NumDigAfterDec Optional. Indicates how many places to the right of the decimal are displayed. Default is -1 (the computer's regional settings are used)
可选项。指示小数点右侧显示位数的数值。默认值为 -1(指示使用的是计算机的区域设置)。
IncLeadingDig Optional. Indicates whether or not a leading zero is displayed for fractional values:
可选项。三态常数,指示是否显示小数值小数点前面的零
  • -2 = TristateUseDefault - 使用计算机区域设置中的设置。
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False
UseParForNegNum Optional. Indicates whether or not to place negative values within parentheses:
可选项。三态常数,指示是否将负值置于括号中
  • -2 = TristateUseDefault - 使用计算机区域设置中的设置。
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False
GroupDig Optional. Indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings:
可选项。三态常数,指示是否使用计算机区域设置中指定的数字分组符号将数字分组。
  • -2 = TristateUseDefault - 使用计算机区域设置中的设置。
  • -1 = TristateTrue - True
  • 0 = TristateFalse - False

实例 1

document.write(FormatNumber(20000))
输出:
20,000.00

实例 2

document.write(FormatNumber(20000.578,2))
输出:
20,000.58

实例 3

document.write(FormatNumber(20000.578,2,,,0))
输出:
20000.58

评论 (0) All

登陆 | 还没注册?