一个字符串,里面包含全角和半角字符,如何取得字符串的长度试了lenB不好用~~~~ 请高手指教~~

解决方案 »

  1.   

    LenB(StrConv(str, vbFromUnicode))
      

  2.   

    LenB(StrConv(String, vbFromUnicode))
      

  3.   

    dim length as integer = len(str)
    dim 你说的长度 as integer = length * 2
    dim arr() as byte = str
    dim i as integer
    for i=0 to ubound(arr)
        if arr(i)=0 then 你说的长度 = 你说的长度 - 1
    next很久不写VB6了,不知道写得对不对,呵呵~
      

  4.   

    没有编码转换,转为byte数组然后遍历,如果有为0的,说明是单字节字符,长度-1