...输入函数对话框输入字母,然后对其分类,分为大小写
发布网友
发布时间:2024-07-03 07:24
我来回答
共4个回答
热心网友
时间:2024-07-23 16:38
sub test()
Dim S As String
Dim C As String
Dim Sl, Su, Sn As String
Dim L As Integer
Dim I As Integer
Dim V As Integer
S = InputBox("请输入一组字符串", "输入")
L = Len(S)
Sl = "": Su = "": Sn = ""
For I = 1 To L
C = Mid(S, I, 1)
V = Asc(C)
If V >= 48 And V <= 57 Then Sn = Sn & C
If V >= 65 And V <= 90 Then Su = Su & C
If V >= 97 And V <= 122 Then Sl = Sl & C
Next I
MsgBox "数字:" & Sn & Chr(13) & "小写:" & Su & Chr(13) & "大写:" & Sl
end sub
热心网友
时间:2024-07-23 16:40
利用ASCII码
大于 97是小a 小于97的是大写的 大小写之间相差 97-65个数值
代码如下:
dim da
dim xiao
a=inputbox("输入字母","输入:","AvAbcdSDSaaBVVV")
lna=len(a)
for i=1 to lna
tem=mid(a,i,1)
if Asc(tem)>=97 then
xiao=xiao & tem
else
da=da & tem
end if
next
msgbox "大写字母有:" & da,,"大写"
msgbox "小写字母有:" & xiao,,"小写"
热心网友
时间:2024-07-23 16:38
4
热心网友
时间:2024-07-23 16:35
Private Sub Form_Load()
Dim strA, strB, strC As String
Dim i As Integer
Dim m As Integer
strB = ""
strC = ""
strA = InputBox("请输入要分辨的字符串", "输入")
strA = Trim(strA)
If strA = "" Then
MsgBox "没有输入任何字符"
Exit Sub
End If
For i = 1 To Len(strA)
m = Asc(Mid(strA, i, 1))
If m <= 90 And m >= 65 Then
strB = strB + Chr(m)
ElseIf m <= 122 And m >= 97 Then
strC = strC + Chr(m)
End If
Next i
MsgBox "大写字母为:" & strB & vbLf & "小写字母为:" & strC
End Sub