显示左边的n个字符(自动识别汉字)函数
发布时间:2006-10-14 2:58:26   收集提供:gaoqian
rem 显示左边的n个字符(自动识别汉字)
Function LeftTrue(str,n)

      If len(str)<=n/2 Then
            LeftTrue=str
      Else
            Dim TStr
            Dim l,t,c
            Dim i
            l=len(str)
            t=l
            TStr=""
            t=0
            for i=1 to l
                  c=asc(mid(str,i,1))
                  If c<0 then c=c+65536
                  If c>255 then
                        t=t+2
                  Else
                        t=t+1
                  End If
                  If t>n Then exit for
                  TStr=TStr&(mid(str,i,1))
            next
            LeftTrue = TStr
      End If

End Function
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50