4个回答
展开全部
多种方法实现:
a = "A"
If Asc(a) > 64 And Asc(a) < 91 Then
MsgBox "大写字母"
ElseIf Asc(a) > 96 And Asc(a) < 123 Then
MsgBox "小写字母"
Else
MsgBox "非字母"
End If
或
If a >= "A" And a <= "Z" Then
MsgBox "大写字母"
ElseIf a >= "a" And a <= "z" Then
MsgBox "小写字母"
Else
MsgBox "非字母"
End If
或
If LCase(a) <> a Then
MsgBox "大写字母"
ElseIf UCase(a) <> a Then
MsgBox "小写字母"
Else
MsgBox "非字母"
End If
a = "A"
If Asc(a) > 64 And Asc(a) < 91 Then
MsgBox "大写字母"
ElseIf Asc(a) > 96 And Asc(a) < 123 Then
MsgBox "小写字母"
Else
MsgBox "非字母"
End If
或
If a >= "A" And a <= "Z" Then
MsgBox "大写字母"
ElseIf a >= "a" And a <= "z" Then
MsgBox "小写字母"
Else
MsgBox "非字母"
End If
或
If LCase(a) <> a Then
MsgBox "大写字母"
ElseIf UCase(a) <> a Then
MsgBox "小写字母"
Else
MsgBox "非字母"
End If
更多追问追答
追问
你好,请问怎样用select语句写一个判断数字的奇偶性的程序?谢谢
追答
a = 123
Select Case a Mod 2
Case 0
MsgBox "偶数"
Case 1
MsgBox "奇数"
End Select
推荐于2017-12-25
展开全部
可以,示例如下:
Dim a As String
a = InputBox("输入一个字符:")
a = Trim(a)
If Len(a) < 1 Then Exit Sub
a = Left(a, 1)
If Asc(a) > 64 And Asc(a) < 91 Then
MsgBox "大写字母"
ElseIf Asc(a) > 96 And Asc(a) < 123 Then
MsgBox "小写字母"
Else
MsgBox "非字母"
End If
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
VB6:
在窗体里新建Text1 Command1
Private Sub Command1_Click()
If Asc(Text1.Text) > 90 Then MsgBox "小写 " & Text1.Text
If Asc(Text1.Text) < 91 Then MsgBox "大写 " & Text1.Text
End Sub
Private Sub Form_Load()
Text1.MaxLength = 1
End Sub
输入一个英文字母(大小写均可) 点按钮判断
在窗体里新建Text1 Command1
Private Sub Command1_Click()
If Asc(Text1.Text) > 90 Then MsgBox "小写 " & Text1.Text
If Asc(Text1.Text) < 91 Then MsgBox "大写 " & Text1.Text
End Sub
Private Sub Form_Load()
Text1.MaxLength = 1
End Sub
输入一个英文字母(大小写均可) 点按钮判断
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Public Enum Cased
isL = 0 '小写
isU = 1 '大写
End Enum
Public Function StrCase(ByVal Text, Optional ByVal TypeVal As Cased = 1)
Select Case TypeVal
Case 0
For i = 1 To Len(Text)
If Asc(Mid(Text, i, 1)) >= 97 And Asc(Mid(Text, i, 1)) <= 122 Then StrCase = 1: Exit For Else StrCase = 0
Next
Case 1
For i = 1 To Len(Text)
If Asc(Mid(Text, i, 1)) >= 65 And Asc(Mid(Text, i, 1)) <= 90 Then StrCase = 1: Exit For Else StrCase = 0
Next
End Select
'返回值1是存在,0是不存在
End Function
Public Function OENumber(ByVal Value)
If Value Mod 2 = 0 Then OENumber = 0 Else OENumber = 1 '0是偶数,1是奇数
End Function
isL = 0 '小写
isU = 1 '大写
End Enum
Public Function StrCase(ByVal Text, Optional ByVal TypeVal As Cased = 1)
Select Case TypeVal
Case 0
For i = 1 To Len(Text)
If Asc(Mid(Text, i, 1)) >= 97 And Asc(Mid(Text, i, 1)) <= 122 Then StrCase = 1: Exit For Else StrCase = 0
Next
Case 1
For i = 1 To Len(Text)
If Asc(Mid(Text, i, 1)) >= 65 And Asc(Mid(Text, i, 1)) <= 90 Then StrCase = 1: Exit For Else StrCase = 0
Next
End Select
'返回值1是存在,0是不存在
End Function
Public Function OENumber(ByVal Value)
If Value Mod 2 = 0 Then OENumber = 0 Else OENumber = 1 '0是偶数,1是奇数
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询