Would you like to react to this message? Create an account in a few clicks or log in to continue.


您沒有登錄。 請登錄註冊

【VB】多重級數運算(等差+等比+費氏)

向下  內容 [第1頁(共1頁)]

1【VB】多重級數運算(等差+等比+費氏) Empty 【VB】多重級數運算(等差+等比+費氏) 周二 3月 15, 2011 11:55 am

Williamd

Williamd
Admin

代碼:

Private Sub Command1_Click()
Label1.Caption = "功能:計算等差級數"
Text1.Text = "首項"
Text2.Text = "公差"
Text3.Text = "項數"
Label2.Caption = ""
End Sub

Private Sub Command2_Click()
Label1.Caption = "功能:計算費氏級數"
Text1.Text = " "
Text2.Text = " "
Text3.Text = "項數"
Label2.Caption = ""
End Sub

Private Sub Command3_Click()
Label1.Caption = "功能:計算等比級數"
Text1.Text = "首項"
Text2.Text = "公比"
Text3.Text = "項數"
Label2.Caption = ""
End Sub

Private Sub Command4_Click()

Dim a1, d, n, t, s, sum As Integer
a1 = Val(Text1.Text)
d = Val(Text2.Text)
n = Val(Text3.Text)
s = a1
sum = 0


For t = 2 To n Step 1
s = s + d
sum = sum + s
Next t

sum = sum + a1

Dim r1, r, rn, rt, rs, rsum As Integer
r1 = Val(Text1.Text)
r = Val(Text2.Text)
rn = Val(Text3.Text)
rs = r1
rsum = 0


For rt = 1 To rn Step 1
rs = r1 * r ^ (rt - 1)
rsum = rsum + rs
Next rt

Dim f1, f2, fn, ft, fs, fsum As Integer
f1 = 1
f2 = 0
fn = Val(Text3.Text)
fs = 0

For ft = 2 To fn Step 1
fs = f1 + f2
fsum = fs
f2 = f1
f1 = fs
Next ft

If Label1.Caption = "功能:計算等差級數" Then

Label2.Caption = sum

ElseIf Label1.Caption = "功能:計算等比級數" Then

Label2.Caption = rsum

ElseIf Label1.Caption = "功能:計算費氏級數" Then

Label2.Caption = fsum

Else

Label2.Caption = "請選擇想要計算的級數"
End If










End Sub



Private Sub Form_Load()

End Sub

Private Sub Text1_Click()
Text1.Text = ""
End Sub

Private Sub Text2_Click()
Text2.Text = ""
End Sub

Private Sub Text3_Click()
Text3.Text = ""
End Sub

※UPLOAD老師的作業...

http://c-wind.luntanlong.com

回頂端  內容 [第1頁(共1頁)]

這個論壇的權限:
無法 在這個版面回復文章