[求助]字符检测方法!!
您好:在vba中有 IsNumberic()函数检测变量是不是数值
但我需要一个能检验所输的变量是不是 字符charactor的函数
或能实现此功能的办法
请多多指点,谢谢!!
写了个函数,只检测位于a-z和A-Z之间的字符。
Function IsCharacter(ByVal Expression As String) As BooleanIsCharacter = False
Dim i As Integer
Dim c As Long
On Error GoTo ErrTrap
If Expression = "" Then Exit Function
IsCharacter = True
For i = 1 To Len(Expression)
c = Asc(Mid(Expression, i, 1))
If Not ((c >= 65 And c <= 90) Or (c >= 97 And c <= 122)) Then
IsCharacter = False
Exit For
End If
Next
Exit Function
ErrTrap:
On Error GoTo 0
End Function
页:
[1]