1樓:匿名使用者
private sub command1_click()dim i as integer, s as integeri = 1
s = 0
while i <= 99
s = s + i
i = i + 2
wend
msgbox "s=1+3+5+...99" + str(s)end sub
你應該是用i來控制迴圈,用s來求和,如果你用s=i+1,那你求的只是一個數,s沒有儲存
2樓:匿名使用者
sub madd()
dim i, ss
for i = 1 to 99 step 2ss = ss + i
next
msgbox "1 to 100 奇數和是: " & ssend sub
3樓:匿名使用者
44444444444444444444444444444
4樓:施忠祖平卉
private
subcommand1_click()
dimsum
aslong
dimi
aslong
fori=1
to100
step
2sum
=sum+i
next
iprint
sumend
sub2500
編寫求1到100之間奇數的和。用vb語言。 10
5樓:匿名使用者
private sub command1_click()dim i, sum1, sum2 as integersum1 = 0
sum2 = 0
for i = 1 to 100
if i mod 2 = 1 then
sum1 = sum1 + i
else
sum2 = sum2 + i
end if
next i
print "奇數
bai和du為zhi" & sum1
print "偶數
dao和為" & sum2
end sub
6樓:匿名使用者
private sub form_click()dim i as long
dim sum as long
sum = 0
for i = 1 to 100 step 2sum = sum + i
next i
print sum
end sub
利用迴圈語句 用vb計算1到100的奇數的和
7樓:微標印象
private sub command1_click()dim i as integer
dim s as integer
for i = 1 to 100
if i mod 2 <> 0 then
s = s + i
end if
next
msgbox s
end sub
c語言求1到100間奇數和以及,c語言求1到100間奇數和以及1 2 3 4 5 100的和
include stdio.h int math1 return sum int math2 sum i return sum int main 第一題 include void main printf d sum 第二題 include void main printf d sum 1 算術方法計...
用VB程式編寫,求奇數和或者偶數和
private sub command1 click dim x as long,y as long,sumx as long,sumy as long x val inputbox 輸入奇數範圍 y val inputbox 輸入偶數範圍 for i 1 to x step 2sumx sumx ...
VB求100以內素數的和,用 vb 做 100以內質數求和 的程式
我是vb初學者,難道沒考慮到什麼嗎,為什麼我想的 就這麼點呢private sub command1 click dim i as integer dim j as integer dim s as integer dim sushu as boolean s 0 for j 2 to 100 su...