VB程式設計利用迴圈實現計算1 2 3 4100的值。怎麼做

時間 2021-05-04 21:50:01

1樓:匿名使用者

public class form1

dim i as integer

dim result as integer = 0private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.

click

for i = 1 to 100

result = result + i

next

textbox1.text = result.tostringend sub

end class

事件通過button1觸發,結果由textbox顯示出來。

2樓:匿名使用者

public class test

system.out.println(sum);}}

看一下吧 剛給你寫的

3樓:匿名使用者

dim t as long

dim m as integer

for m= 1 to 100

t=m+t

next m

4樓:匿名使用者

dim i as long, counter as longfor i = 1 to 99

counter = counter + inext

msgbox counter

測試無誤

5樓:匿名使用者

private sub form_click()dim sum, i as integerdo while i <= 100

s = s + i

i = i + 1

loop

print s

end sub

6樓:

private sub form_click()dim i as integer, counter as integer

for i = 1 to 100

counter = counter + inext

msgbox counter

end sub

vb程式設計計算1+2+3+4……+100的值

7樓:紅山人

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中運用計數迴圈結構計算出1+2+3+4+......+100的結果**?

8樓:匿名使用者

private sub form_click()dim s as integer, i as integers = 0

i = 1

dos = s + i

i = i + 1

loop until i = 101

print "s="; s

end sub

執行結果:

s= 5050

9樓:匿名使用者

vb你都會,地球人真是無法阻擋你了,

用vb程式編寫一個過程來計算1+2+3+4+……+100的值。

10樓:因特兒

private sub command1_click()dim sum as integer '定義變數sum,i為整形dim i as integer

sum=0'給sum賦值

for i = 1 to 100 』for迴圈sum = sum + i '迴圈過程每次給sum加一next i

print sum 』輸出sum和

end sub

11樓:匿名使用者

dim a as integer '首項

dim b as integer '末項

dim c as integer '項數

dim d as integer '結果

public sub add()

a = inputbox("首項", "")b = inputbox("末項", "")c = inputbox("項數", "")d = (a + b) * c / 2

msgbox d

end sub

private sub form_load()call add

end sub

針對這個問題首項=1,末項=100,項數=100end sub

12樓:

private sub button1_click()dim i as integer, j as integerj = 0

for i = 1 to 100

j += i

next i

msgbox(j)

end sub

vb程式設計求1+2+3+4+……+100的值怎麼編

13樓:匿名使用者

dim i as integer,n as integerfor i=1 to 100

n=n+i

next

print n

vb程式設計 利用隨機函式產生10 99之間的隨機整數

option explicit private sub command1 click dim a 80 as integer,b as integer,nb as integer dim i as integer,j as integer,t as integer 隨機生成80個隨機數 text1....

VB程式設計題,VB程式設計練習題?

1.新建工程 工程1 2.新建一下combobox控制元件 combo1,並將屬性style改為2 3.新建五個label label1,label2,label3,label4,label5 4.新建兩個text文字框 text1,text2 5.新建一個commandbutton按鈕 comma...

VB程式設計

在用print輸出的時候在輸出後面加個 號就可以連在一起了,比如 print 123 要是想五個一行就用個迴圈 for i 1 to 5 print 你要輸出的東西 next i 這樣就會是5個一行了 給你段 僅做參考 private sub dim i j a 4 ran.這初始化單詞不會了,自己...