Private Function cs(A As Range) As String
Application.Volatile
Dim lo, strtyp1, strtyp2, c, d As Integer
Dim lu%, hw$, hx$
Dim hw, hx
lo = LenB(A)
For lu = 1 To lo
hw = Mid(A, lu, 1)
hx = Mid(A, lu + 1, 1)
c = Asc(hw)
d = Asc(hx)
'对当前字符进行判断
If c > 255 Or c < 0 Then '判断汉字 并赋值
strtyp1 = 1
Else
If (c >= 0 And c < 48) Or (c >= 58 And c <= 255) Then '判断字母 并赋值
strtyp1 = 2
Else
If c < 58 And c >= 48 Then '判断数字 并赋值
strtyp1 = 3
End If
End If
End If
'对下一个字符进行判断
If d > 255 Or d < 0 Then
strtyp2 = 1
Else
If (d >= 0 And d < 48) Or (d >= 58 And d <= 255) Then
strtyp2 = 2
Else
If d < 58 And d >= 48 Then
strtyp2 = 3
End If
End If
End If
'比较前后两个字符,如果类型不一致,则加一个分隔符
If strtyp1 > strtyp2 Or strtyp1 < strtyp2 Then
hw = hw & "\"
cs = cs & hw
'lu = lu + 1
'lo = lo + 1
Else
hw = hw
cs = cs & hw
End If
'cs = cs & hw
Next
'cs = cs & hw
End Function