可以这样来定义
dim a1 as string 
a1 = space(5)...
a1 = trim(a1)
if right(a1,1) = chr(0) then
   a1 = left(a1,len(a1)-1)
end if

解决方案 »

  1.   

    '方法:获取字符串长度VB6中   GetStrLen
    '功能说明:获取字符串长度
    '参数说明:
    '   Txt  字符串  as string
    '
    '返回值说明:返回数据类型为长整型 as long
    '权限说明:所有使用者
    '作者:
    '更改:
    '创建时间:20011120
    '最后修改日期:20011121    Public Function GetStrLen(ByVal Txt As String) As Long
            Dim tmpI As Long
            '初始化
            GetStrLen = 0
            '执行
            If Len(Txt) = 0 Then
                GetStrLen = 0
                Exit Function
            End If
            
            For tmpI = 1 To Len(Txt)
                If Asc(Mid(Txt, tmpI, 1)) < 0 Then
                    GetStrLen = GetStrLen + 2
                    Else
                    GetStrLen = GetStrLen + 1
                End If
            Next tmpI
            '结束
        End Function
      

  2.   

    LenB(StrConv(RTrim(al), vbConvANSI))
      

  3.   

    我贊成 qkaizhou(御赐金牌小密探!) 的做法﹐確實比較好