输入一字符串,统计小写字母的个数,并输出结果。用VB怎么写
答案:3 悬赏:30
解决时间 2021-02-15 05:09
- 提问者网友:喵星人荷西
- 2021-02-14 06:58
输入一字符串,统计小写字母的个数,并输出结果。用VB怎么写
最佳答案
- 二级知识专家网友:情战凌云蔡小葵
- 2021-02-14 07:33
Private Sub Command1_Click()
s = Len(Text1)
For i = 1 To s
If Mid(Text1, i, 1) <> 32 Then '没空格
If 97 < Asc(Mid(Text1, i, 1)) And Asc(Mid(Text1, i, 1)) < 122 Then a = a + 1 '小写字母
If 65 < Asc(Mid(Text1, i, 1)) And Asc(Mid(Text1, i, 1)) < 90 Then b = b + 1 '大写的
If 48 < Asc(Mid(Text1, i, 1)) And Asc(Mid(Text1, i, 1)) < 57 Then c = c + 1 '数字
End If
Print d
Next i
Print "小写字母" & a & "个"
Print "大写字母" & b & "个"
Print "数字" & c & "个"
Print "其它(包括空格)" & s - a - b - c & "个"
Print s
End Sub
s = Len(Text1)
For i = 1 To s
If Mid(Text1, i, 1) <> 32 Then '没空格
If 97 < Asc(Mid(Text1, i, 1)) And Asc(Mid(Text1, i, 1)) < 122 Then a = a + 1 '小写字母
If 65 < Asc(Mid(Text1, i, 1)) And Asc(Mid(Text1, i, 1)) < 90 Then b = b + 1 '大写的
If 48 < Asc(Mid(Text1, i, 1)) And Asc(Mid(Text1, i, 1)) < 57 Then c = c + 1 '数字
End If
Print d
Next i
Print "小写字母" & a & "个"
Print "大写字母" & b & "个"
Print "数字" & c & "个"
Print "其它(包括空格)" & s - a - b - c & "个"
Print s
End Sub
全部回答
- 1楼网友:堕落奶泡
- 2021-02-14 09:07
,rit9gmitu
- 2楼网友:单身小柠`猫♡
- 2021-02-14 08:29
dim R as string,i as integer,n as integer
R=inputbox("请输入字符串:")
for i=1 to len(r)
if asc(mid(r,i,1))>=97 and asc(mid(r,i,1))<=122 then n=n+1
next i
print "共有小写字母";n;"个。"
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯