VB编程:输入一个字符串,判断其中有多少大写字母小写字母数字字符空
1个回答
展开全部
dim Num1 as integer,Num2 as integer
dim Num3 as integer,Num4 as integer,Num5 as integer
dim i as integer
dim s as string
s = InputBox("输入字符串:")
for i = 1 to Len(s)
if mid(s,i,1)>="A" And mid(s,i,1)<="Z" Then
Num1 = Num1 + 1
elseif mid(s,i,1)>="a" And mid(s,i,1)<="z" Then
Num2 = Num2 + 1
elseif mid(s,i,1)>="0" And mid(s,i,1)<="9" Then
Num3 = Num3 + 1
elseif mid(s,i,1) =" " Or mid(s,i,1)=" " Then
Num4 = Num4 + 1
else
Num5 = Num5 + 1
end if
next i
print "大写字母有:";Num1;"个"
print "小写字母有:";Num2;"个"
print "数字字符有:";Num3;"个"
print "空格字符有:";Num4;"个"
print "其它字符有:";Num5;"个"
dim Num3 as integer,Num4 as integer,Num5 as integer
dim i as integer
dim s as string
s = InputBox("输入字符串:")
for i = 1 to Len(s)
if mid(s,i,1)>="A" And mid(s,i,1)<="Z" Then
Num1 = Num1 + 1
elseif mid(s,i,1)>="a" And mid(s,i,1)<="z" Then
Num2 = Num2 + 1
elseif mid(s,i,1)>="0" And mid(s,i,1)<="9" Then
Num3 = Num3 + 1
elseif mid(s,i,1) =" " Or mid(s,i,1)=" " Then
Num4 = Num4 + 1
else
Num5 = Num5 + 1
end if
next i
print "大写字母有:";Num1;"个"
print "小写字母有:";Num2;"个"
print "数字字符有:";Num3;"个"
print "空格字符有:";Num4;"个"
print "其它字符有:";Num5;"个"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询