vb編寫一程式計算s 1 3 521,要求將結果顯示到標籤控制件中

2022-12-13 05:55:17 字數 926 閱讀 6507

1樓:匿名使用者

不確定項數的方法通常是使用do/whileprivate sub command1_click()dim i as integer,s as longi = 1

do while i <= 21

s = s + i

i = i + 2

loop

label1.caption = "計算結果" & cstr(s)end sub

用for 也沒問題 step 2 就可以了

2樓:vb妮可

dim i& ,s&

s=0for i=1 to 21 step 2s=s+i

next

label1.caption=s

3樓:匿名使用者

function s(byval a as integer) as integer

return (a * (a + 1)) / 2end function

sub text()

label1.text = s(21)

end sub

4樓:

dim a1&,an&,n&

a1=1:an=21:n=11

label1=(a1+an)/2*n

5樓:

在vb視窗中新增一個標籤,將它的caption屬性設定為空(就是不寫),將標籤的borderstyle屬性設定為1-fix single然後按f7開啟**視窗;**如下:

private sub form_click()dim s as integer,i as integerfor i=1 to 21 step 2

s=s+i

next i

label1.caption=str(s)end sub

用VB編寫程式,計算求123456200的值

dim n as long,m as longdim i as long n val text1.text m 0for i 1 to n m m 1 i i next i text2.text m end sub 用vb程式設計計算1 2 3 4 5 6 n的值,n由文字框輸入 樓上的程式,個人認...

用VB程式編寫過程來計算1 2 3 4100的值

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 輸出s...

vb編寫用於求隨機數的程式,vb編寫一個用於求隨機數的程式

private sub form mousedown button as integer,shift as integer,x as single,y as single dim i as integer,f as doublerandomize if button vbkeylbutton the...