LCase UCase比较简单。vbscript用它来转换大小写.
UCase(string) string 参数是任意有效的字符串表达式。如果 string 参数中包含 Null,则返回 Null。
说明 只有小写字母被转换成大写字母;所有大写字母和非字母字符均保持不变。
下面的示例利用 UCase 函数返回字符串的大写形式:
Dim MyWord MyWord = UCase("Hello World") ' 返回"HELLO WORLD"。
LCase 函数 请参阅 返回字符串的小写形式。
LCase(string) string 参数是任意有效的字符串表达式。如果 string 参数中包含 Null,则返回 Null。
说明 仅大写字母转换成小写字母;所有小写字母和非字母字符保持不变。
下面的示例利用 LCase 函数把大写字母转换为小写字母:
Dim MyString Dim LCaseString MyString = "VBSCript" LCaseString = LCase(MyString) ' LCaseString 包含 "vbscript"。
len函数也相对简单,返回字符串的长度。
返回字符串内字符的数目,或是存储一变量所需的字节数。
Len(string | varname) 参数 string 任意有效的字符串表达式。如果 string 参数包含 Null,则返回 Null。 Varname 任意有效的变量名。如果 varname 参数包含 Null,则返回 Null。 说明 下面的示例利用 Len 函数返回字符串中的字符数目:
Dim MyString MyString = Len("VBSCRIPT") 'MyString 包含 8。 注意 LenB 函数与包含在字符串中的字节数据一起使用。LenB 不是返回字符串中的字符数,而是返回用于代表字符串的字节数。
dim str:str="asp学习网" dim strlen0:strlen0=len(str)
dim strlen1:strlen1=lenb(str) Response.write strlen0 '输出6
Response.write strlen1 '输出10 一个汉字两个字节 当写入数据库的时候,如果字段是text,也会占两个长度。
Left 函数
返回指定数目的从字符串的左边算起的字符。
Left(string, length) 参数 string 字符串表达式,其最左边的字符被返回。如果 string 参数中包含 Null,则返回 Null。 Length 数值表达式,指明要返回的字符数目。如果是 0,返回零长度字符串 ("");如果大于或等于 string 参数中的字符总数,则返回整个字符串。 说明 可使用 Len 函数确定 string 参数中的字符数目。
下面的示例利用Left 函数返回MyString 的左边三个字母:
Dim MyString, LeftString MyString = "VBSCript" LeftString = Left(MyString, 3) 'LeftString 包含 "VBS"。 注意 LeftB 函数与包含在字符串中字节数据一起使用。length 不是指定返回的字符串数,而是字节数。 参考前面提到的lenb,容易理解。
Right 函数 从字符串右边返回指定数目的字符。
Right(string, length) 参数 string 字符串表达式,其最右边的字符被返回。如果 string 参数中包含 Null,则返回 Null。 Length 数值表达式,指明要返回的字符数目。如果为 0,返回零长度字符串;如果此数大于或等于 string 参数中的所有字符数目,则返回整个字符串。 说明 要确定 string 参数中的字符数目,使用 Len 函数。
下面的示例利用 Right 函数从字符串右边返回指定数目的字符:
Dim AnyString, MyStr AnyString = "Hello World" ' 定义字符串。 MyStr = Right(AnyString, 1) ' 返回 "d"。 MyStr = Right(AnyString, 6) ' 返回 " World"。 MyStr = Right(AnyString, 20) ' 返回 "Hello World"。 注意 RightB 函数用于字符串中的字节数据,length 参数指定返回的是字节数目,而不是字符数目。
更多参考
http://www.aspxuexi.com/code/2006-5-18/function_getStrValue.htm
http://www.aspxuexi.com/code/2006-5-14/str_sp.htm
|