vb编程从1-100中选出带有数字7的并求和

2024-11-06 02:38:18
推荐回答(1个)
回答1:

vb编程从1-100中选出带有数字7的并求和
dim R as long
dim lSum as long

dim lFlag as long

for R = 1 to 100
if R mod 5 = 0 or R mod 7 = 0 then
debug.print R & VbTab;
if lFlag mod 5 = 0 then
debug.print
end if
lFlag=lFlag+1

lSum=lSum + R
end if
next

debug.print "1-100之间的所有是5或7的倍数的数之和为:" & lSum