1.Len函数
(Long),如: 
Dim A as  String
Dim B as  Integer
A= "我是中国人" '初始化字符串
B=Len(A)      '返回10(一个汉字占2字节)
  • 1.
  • 2.
  • 3.
  • 4.
、Ltrim及Rtrim函数
  Trim、Ltrim及Rtrim函数完成将字符串中的一部分或全部空格去掉。Trim去掉字符串中的全部空格,Ltrim去掉字符串中起始的空格,而Rtrim将字符串末尾的空格都去掉,例如:
Dim A,B  As String
A= " hello "     '初始化字符串
B=Trim(A)        'B="hello"
B=Ltrim(B)       'B="hello "
B=Rtrim(B)     'B=" hello"
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
方法,用于截取字符串的某部分
  Substring方法取代以前vb 6.0中的"Right"、"Left"及"Mid"等标准函数,用法是:
    StrName.Substring(startChar,Length)
  例如:

    Dim A as String

    A.Substring(0,2) '相当于Left(S,2),结果en
    A.Substring(S.Length(),-4) '相当于Right(S,4),结果name

作者:꧁执笔小白꧂