left函数的用法

来源:百度知道 编辑:UC知道 时间:2024/05/15 10:24:22
如何从左取字符串的中间一段.

描述
返回指定数目的从字符串的左边算起的字符。
语法
Left(string, length)
Left 函数的语法有以下参数:

参数 描述
string 字符串表达式,其最左边的字符被返回。如果 string 参数中包含 Null,则返回 Null。
length 数值表达式,指明要返回的字符数目。如果是 0,返回零长度字符串 ("");如果大于或等于 string 参数中的字符总数,则返回整个字符串。

说明
可使用 Len 函数确定 string 参数中的字符数目。
下面的示例利用Left 函数返回MyString 的左边三个字母:

Dim MyString, LeftString
MyString = "VBSCript"
LeftString = Left(MyString, 3) 'LeftString 包含 "VBS"。

--------------------------------------------------------------------------------

注意 LeftB 函数与包含在字符串中字节数据一起使用。 length 不是指定返回的字符串数,而是字节数。

--------------------------------------------------------------------------------