VB程式求和,VB程式設計計算求和

2022-01-13 10:40:12 字數 2606 閱讀 4532

1樓:

程式本身有2處錯誤:

1.變數 s 不能申明為 integer,應為 single2.語句 s = ② 將改變 s 的值,導致無法得到正確結果因此,不改變程式結構永遠得不到正確結果

完整序列為:

1/1 + 1/2 + 2/3 + 3/5 + 5/8 + 8/13 +

13/21 + 21/34 + 34/55 + 55/89private sub command1_click()dim s as single

dim a as integer

dim b as integer

dim k as integer

dim j as integer

s = 0

a = 1

b = 1

for k = 1 to 10 '第 7 項是 21/34s = s + a / b

j = a

a = b

b = b + j

next

msgbox s

print s

end sub

2樓:匿名使用者

題目的序列給的不清晰,無法做答!!!

您的題目根本不是 程式題目,而是數學考試

很多人會因為無法推導出正確的公式來,而無法完成程式的!!!!!!!!!

vb程式設計計算求和

3樓:窩窩小墨

我用自己的辦法幫你吧. private sub command1_click() open "c:\documents and settings\11111\桌面\新建 文字文件.

txt" for input as #1 do while not eof(1) line input #1, ss list1.list(k) = ss k = k + 1 loop close #1 end sub private sub command2_click() dim s1, s2, s3, s4, s5, s6 as integer s1 = 0 s2 = 0 s3 = 0 s4 = 0 s5 = 0 s6 = 0 for i = 0 to list1.listcount - 1 s1 = s1 + mid(list1.

list(i), 1, 2) s2 = s2 + mid(list1.list(i), 4, 2) s3 = s3 + mid(list1.list(i), 7, 2) s4 = s4 + mid(list1.

list(i), 10, 2) s5 = s5 + mid(list1.list(i), 13, 2) s6 = s6 + mid(list1.list(i), 16, 2) next i text1.

text = s1 & "," & s2 & "," & s3 & "," & s4 & "," & s5 & "," & s6 end sub

用vb編寫累加求和的程式

4樓:

'文字框名字分別預設為text1,text2,text3'加乙個按鈕名字預設為command1

sub command1_click()

dim sum as integer, i as integersum=0

for i=cint(text1.text) to cint(text2.text)

sum=i+sum

next

text3.text=sum

end sub

'137yy真會yy,汗。

5樓:匿名使用者

不是很明白你的問題!說具體點!我是vb高手

vb 程式設計實現 加數 求和

6樓:匿名使用者

public function f(byval n as integer) as integer

dim i as integer

dim sum as integer

sum = 0

for i = 1 to n

sum = sum + i

next i

f = sum

end function

private sub command1_click()dim n as integer, i as integerdim sum as double

sum = 0

n = inputbox("請輸入乙個數字n")for i = 1 to n

sum = sum + f(i)

next i

print sum

end sub

7樓:匿名使用者

function add(n as integer) as integer

dim i as integer,j as integer,temp as integer

for i=1 to n

for j=1 to i

temp = temp+j

next

next

add = temp

end function

sub test()

debug.print add(5)end

vb試題程式設計計算,vb試題程式設計計算

1 dim i as integer dim s as double dim s0 as double for i 1 to 100 s0 1 i if i mod 2 0 then s0 s0 1 s s s0 next print s 2 dim i as integer dim s as do...

VB程式設計題設計用於設定字型屬性的程式具體如下

把以下 用記事本儲存為字尾名為.frm的檔案中,用vb開啟。version 5.00 begin vb.form form1 caption form1 clientheight 3195 clientleft 60 clienttop 345 clientwidth 4680 linktopic ...

關於VB的程式設計問題編,寫加密程式爆急啊

private sub command1 click 用每個字母的ascii碼加7,相加之後的ascii碼值若超過90但不超過97,則減去10,若超過122,則減去8。dim a,b as integer a asc left text1.text,1 7b asc right text1.text...