谢谢大家的建议,修改了代码,基本实现了想法,代码如下:
Sub test()
Dim sr As String
Do
sr = InputBox("请输入一个字符")
If Len(sr) = 0 Then
MsgBox "字符不能为空,请重新输入"
ElseIf Len(sr) > 1 Then
MsgBox "字符长度超出2位,请重新输入"
Else
Exit Do
End If
Loop
If sr >= "a" And sr <= "z" Then
MsgBox "您输入的是小写字母"
ElseIf sr >= "A" And sr <= "Z" Then
MsgBox "您输入的是大写字母"
ElseIf sr >= "0" And sr <= "9" Then
MsgBox "您输入的是数字"
Else
MsgBox "您输入的是其他字符"
End If
End Sub
Sub test()
Dim sr As String
Do
sr = InputBox("请输入一个字符")
If Len(sr) = 0 Then
MsgBox "字符不能为空,请重新输入"
ElseIf Len(sr) > 1 Then
MsgBox "字符长度超出2位,请重新输入"
Else
Exit Do
End If
Loop
If sr >= "a" And sr <= "z" Then
MsgBox "您输入的是小写字母"
ElseIf sr >= "A" And sr <= "Z" Then
MsgBox "您输入的是大写字母"
ElseIf sr >= "0" And sr <= "9" Then
MsgBox "您输入的是数字"
Else
MsgBox "您输入的是其他字符"
End If
End Sub