1樓:匿名使用者
因為不知道你所寫的**,所以僅僅將vb中「累加」**呈上即可:
dim i as integer, sum as integersum = 0
『使用迴圈將1至100累加到變數sum中
for i = 1 to 100
sum = sum + i
next i
print "s=1+2+3+...+100=" & sum
2樓:匿名使用者
public class form1
private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.
click
dim i as integer, s as integerfor i = 1 to 100
s = s + i
next
textbox1.text = s.tostringend sub
end class
3樓:匿名使用者
private sub command1_click()sum = 0
for i = 1 to 100
sum = sum + i
next i
print sum
end sub
這是我覺得最簡單的了,你應該會學會的,加油
vb程式設計計算:1+2!+3!+...+10!
4樓:匿名使用者
private sub command1_click()dim i as integer, j as integerdim l as long, h as longfor i = 1 to 10
h = 1
for j = 1 to i
h = h * j
next
l = l + h
next
print l
end sub
5樓:岔路程式緣
private sub form_click()
form1.autoredraw = true
me.show
dim sum as long, i as integer, j as integer
sum = 0
for i = 1 to 10
sum = sum + jc(i)
next
print "s=1+2!+3!+...+10!="; sum
end sub
private function jc(x as integer) as long
if x = 1 then jc = 1 else jc = x * jc(x - 1)
end function
或(do while loop ):
private sub form_click()
form1.autoredraw = true
me.show
dim sum as long, i as integer, j as integer
sum = 0
i=1do while i <= 10
sum = sum + jc(i)
i=i+1
loop
print "s=1+2!+3!+...+10!="; sum
end sub
private function jc(x as integer) as long
if x = 1 then jc = 1 else jc = x * jc(x - 1)
end function
6樓:亓靖瀅
dim i as integer
dim sum as integer
dim n as integer
n = 1
sum = 0
for i = 1 to 10
n = n * i
sum = sum + n
next
print(sum)
7樓:宿思敏羿宣
vb程式設計計算2+2^1+2^2+2^3+......+2^10private
subcommand1_click()
dimi%,s%s
=2fori=1
to10s=
s+2^
inext
iprint
send
subvb程式設計求出100-200以內的同時能被3和5整除的所有整數private
subcommand1_click()
dimi
asinteger
fori
=100
to200ifi
mod3=0
andi
mod5=0
then
i;end
ifnext
iend
subvb程式設計計算1-2+3-4+5-6……+-n,其中n由文字框輸入
private
subcommand1_click()
dimi%,
k%,s%k=
1fori=
1toval(text1.text)s=
s+i*
kk=-k
next
iprint
sendsub
vb程式設計,求1!+2!+3!+…+20!。謝謝!
8樓:匿名使用者
第乙個文字框(要求填入多少由你決定)
for i = 1 to text1.textb = b +i
next i
text2.text= b
將結果輸出到文字框二
9樓:鬱渟
sub test()
dim i as integer, x as double, y as double
x = 1
y = 0
for i = 1 to 20
x = x * i
y = y + x
next
msgbox y
end sub
10樓:牛人影視
privae sub command1_click()dim i as integer,s as longfor i=1 to 20
s=s+jc(i)
next i
msgbox s
end sub
private function jc(x as integer) as long
dim i as integer
jc=1
for i=1 to x
jc=jc*i
next i
end function
11樓:匿名使用者
n=20
s=0j=1
for i= 1 to n
j=j*i
s=s+j
next
msgbox s
12樓:匿名使用者
樓下的 回答 都挺好的.. 就是靠迴圈哦~~
用vb 編寫程式,計算1+2+3……+100的和。
13樓:匿名使用者
private sub form_load()dim i,s as integer
s=0for i=1 to 100
s=s+i
next i
print s
end sub
14樓:匿名使用者
dim i as integer, sum as integersum = 0
for i = 1 to 100
sum = sum + i
next i
print sum
編寫程式,計算s=1+2+3+……100的整數之和 20
15樓:匿名使用者
源**如下:
#include
#include
void main()
printf("整數之和是:%d\n", sum);
getchar();
}執行結果如下圖:
16樓:守望海之依賴
int i = 0,sum = 0;
for( i=1;i<=100;i++ )
17樓:匿名使用者
private static void main(string args)
console.writeline("1加到100的和為: "+sum);}
vb程式設計計算1+2+3+4……+100的值
18樓:紅山人
private sub form_click()dim s as integer
for i = 1 to 100
s = s + i
next i
print "1+2+....+100="; send sub
VB程式設計求S 1 1 4 ,VB程式設計求S 1 1 2 1 3 1 4
前舞苟念寒 option explicit private subcommand1 click dimi asinteger,sas single fori 1 to100s s 1 i 1 1 i next print send sub 其實只要知道 1的奇數次方為 1就可以簡化很多 鄧佩蘭懷莞 ...
程式設計完成功能 求SUM 1 2 3100,並求出累加的最後自然數的值
男人海洋 vb或者vba private sub commandbutton1 click dim message,title,default,myvalue dim i,j,k message 輸入100或其他 設定提示資訊。title 求sum 1 2 3 100,求出累加的最後乙個自然數的值 ...
急求!vb程式設計題目
dim m as integer,n as integerprivate sub command1 click m val inputbox 輸入正整數 n val inputbox 輸入正整數 if n m 0 then msgbox 兩數任何乙個數都不能為0 exit sub end if en...