文档详情

vb.net格式化字符串.pdf

发布:2016-03-11约7.1千字共5页下载文档
文本预览下载声明
格式化函数 一 日期时间格式化函数 语法:FormatDateTime (exp As DateTime [, namedformat As DateFormat ]) As String 说明:依照参数namedformat 指定的格式将参数exp 的日期格式化,选择性参数namedformat 属 于DateFormat 枚举,成员如下: (1)DateFormat.GeneralDate:显示日期和(或)时间。若有日期部分,则会显示为简短日期;若 有时间部分,则会显示为完整时间;若两者皆有,则会全显示。 (2)DateFormat.LongDate:使用计算机的区域选项中所指定的完整日期格式显示日期。 (3)DateFormat.ShortDate:使用计算机的区域选项中所指定的简短日期格式显示日期。 (4)DateFormat.LongTime:使用计算机的区域选项中所指定的时间格式来显示日期。 (5)DateFormat.ShortTime:使用24 小时制(hh : mm)来显示时间。 如:FormatDateTime (#2/14/2002#, DateFormat.LongDate)会返回“2002 年2 月14 日”; FormatDateTime (#2/14/2002#, DateFormat.ShortDate)会返回“2002/2/14”。 二 货币值格式化函数FormatCurrency () 语法:FormatCurrency (exp As Object [, numdigitsafterdecimal As Integer [, leadingdigit As Tristate [,negparen As Tristate [,groupDigits As TriState ]]]]) As Strong 说明:将参数exp 设置成指定的货币格式,此货币值使用控制面板中区域选项所定义货币符。选择性参 数numdigitsafterdecimal 表示要显示小数点后面几们数,-1 为采取系统默认值;选择性参数 leadingdigit 表示是否要在小于 1 的值前面加上0,属于Tristate 枚举,成员如下表所示;选择性参数 negparen 表示是否要将负数用括号起来,属于Tristate 枚举;选择性参数groupdigits 表示加上分隔符 来组合数字,属于Tristate 枚举。例如: FormatCuurnct (12345.789, 2)会返回 NT$123,456.79 Tristate 枚举成员 值 Tristate.True True Tristate.False False Tristate.UseDefault 区域选项的设置 三 数值格式化函数FormatNumber () 语法:FormatNumber (exp As Object [, numdigitsafterdecinnal As Integer [,leadingdigit As Tristate [,negparen As Tristate [,Groupdigits As Tristate ]]]] As String 说明:将参数exp 设置成指定的数值格式。选择参数同上(即同货币值函数参数) 四 百分比格式化函数FormatPerCent () 语法:FormatPerCent (exp As Object [, numdigitsafterdecinnal As Integer [,leadingdigit As Tristate [,negparen As Tristate [,Groupdigits As Tristate ]]]] As String 说明:将参数exp 设置成指定的百分比格式(乘以100)选择性参数同上。 五 格式化函数Format () 语法:Format (exp As Object [, style As String]) As String 说明:根据style 指定格式将exp 格式化。选择性参数style 为任何预先定义的格式化表达式或用户自 定义的格式化表列,如下两个表: 预定义的格式
显示全部
相似文档