cstr()函数的意思

来源:百度知道 编辑:UC知道 时间:2024/05/22 05:28:31

将括号中的内容转换为字符串,括号中的内容可以是值、变量或表达式
如以下均为合法:
dim a as Integer
dim b as string
a=155
b=cstr(a) 'b的值就是"155"
b=cstr(155) 'b的值也是"155"
b=cstr(a+2) 'b的值是"157"

字符转换函数
强制将一个表达式转换成字符型数据类型

CStr String 依据 expression 参数返回 Cstr。
CStr 返回值

如果 expression 是 CStr 返回
Boolean 含有 True或 False 的字符串
Date 含有系统中短日期格式日期的字符串
Null 一个运行时错误
Empty 一个零长度字符串 ("")
Error 包含单词 Error 以及错误号的字符串
其他数值 含有数值的字符串
CStr
Returns an expression that has been converted to a Variant of subtype String.

Syntax
CStr(expression)

The expression argument is any valid expression.

Remarks
In general, you can document your code using the data type conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CStr to force the result to be