VB求助:在一个五位数中有几个是7?尝试用If..Then..Else 嵌套Select..Case,但是比较复杂,求简单代码

2024-11-23 04:50:39
推荐回答(3个)
回答1:

a=34567
for i=1 to len(a)
if mid(a,i,1)=7 then n=n+1
next
print n

回答2:

dim a,num
a="23767"
num=0
for i=1 to len(a)
if mid(a,i,1) mod 7=0 then
num=num+1
end if
next
msgbox "一共有"&num&"个7"

回答3:

dim n as integer, m as integer, count as integer;
n = 12345
while n>10
m = n mod 10
if m = 7 then
count= count+1
end if
n = n \ 10
wend
if n = 7 then
count = count +1
end if
msgbox "有" & count & "个7“