Function UCaseStr(ByVal str As String) As String Dim s As String str = Trim(str) If str = "" Then Exit Function For i = 1 To Len(str) s = Mid(str, i, 1) If s Like "[a-z]" Then UCaseStr = UCaseStr & Chr(Asc(s) - 32) Else UCaseStr = UCaseStr & s End If Next End Function
Function LtoU(L As String) As String LtoU = Chr(Asc(L) - 32) End Function
Dim s As String
str = Trim(str)
If str = "" Then Exit Function
For i = 1 To Len(str)
s = Mid(str, i, 1)
If s Like "[a-z]" Then
UCaseStr = UCaseStr & Chr(Asc(s) - 32)
Else
UCaseStr = UCaseStr & s
End If
Next
End Function
LtoU = Chr(Asc(L) - 32)
End Function
不用系统函数.用自己建的函数.呵
s+A-a
ACSII码是-32,但非ACSII码呢?这个问题在《C陷阱与缺陷》中有讲解,我们应该尽量保证不出错和可移值性问题。