当前位置:编程学习 > VB >>

输入一字符串,统计小写字母的个数,并输出结果。用VB怎么写

答案: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
其他:,rit9gmitu 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;"个。" 

上一个:拜托你再帮一个忙~VB代码就行~谢谢~~
下一个:vb中的必选参数是什么意思啊?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,