level 8
lscx521
楼主
这几天在写一个辅助工具,遇到个需要处理字符串长度省略的问题,自己写了一个,并不是很难,给大家分享一下
Private Function GetzfLen(zf As String) As String
Dim i As Integer, a As Integer, b As Integer
For i = 1 To Len(zf)
If Asc(Mid(zf, i, 1)) >= 0 And Asc(Mid(zf, i, 1)) <= 255 Then
a = a + 1
Else
b = b + 1
End If
If i < Len(zf) Then
If b + Int(a / 2) >= 19 Then
GetzfLen = Left(zf, i) & "..."
Exit Function
End If
End If
Next i
If b + Int(a / 2) <= 20 Then GetzfLen = zf: Exit Function
End Function
2011年06月14日 08点06分
1
Private Function GetzfLen(zf As String) As String
Dim i As Integer, a As Integer, b As Integer
For i = 1 To Len(zf)
If Asc(Mid(zf, i, 1)) >= 0 And Asc(Mid(zf, i, 1)) <= 255 Then
a = a + 1
Else
b = b + 1
End If
If i < Len(zf) Then
If b + Int(a / 2) >= 19 Then
GetzfLen = Left(zf, i) & "..."
Exit Function
End If
End If
Next i
If b + Int(a / 2) <= 20 Then GetzfLen = zf: Exit Function
End Function