Table of contents
TOC
折叠目录
展开目录

Str 函数Str Function

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

返回一个variant 类型的值字符串) 表示一个数。语法Str数字)要求的_数字_参数包含任何有效的数值表达式备注当数字转换为字符串时,将始终为_number_的符号保留一个前导空格。如果_number_为正,则返回的字符串包含前导空格,并暗含加号。使用Format函数转换您需要格式化为日期、 时间或货币或者其他用户定义格式的数值。与不同的StrFormat函数不包含前导空格的符号_数_。Returns a Variant ( String ) representation of a number. SyntaxStr ( number ) The required numberargument is aLong containing any validnumeric expression. Remarks When numbers are converted to strings, a leading space is always reserved for the sign of number. If number is positive, the returned string contains a leading space and the plus sign is implied. Use the Format function to convert numeric values you want formatted as dates, times, or currency or in other user-defined formats. Unlike Str, the Format function doesn't include a leading space for the sign of number.

请注意Str函数只将句点 ( . ) 识别为有效的小数点分隔符。如果要使用不同的小数点分隔符 (例如在国际应用程序中),请使用CStr将数字转换为字符串。Note The Str function recognizes only the period ( . ) as a valid decimal separator. When different decimal separators may be used (for example, in international applications), use CStr to convert a number to a string.

示例Example

本示例使用Str函数返回数字的字符串表示形式。当数字转换为字符串时,将始终为其符号保留一个前导空格。This example uses the Str function to return a string representation of a number. When a number is converted to a string, a leading space is always reserved for its sign.

Dim MyString
MyString = Str(459)    ' Returns " 459".
MyString = Str(-459.65)    ' Returns "-459.65".
MyString = Str(459.001)    ' Returns " 459.001".

© 2018 Microsoft