請高手編一個VB疊代程序,方程式爲:lnP = A - B/T + C*lnT + D*P/T^2

題目:

請高手編一個VB疊代程序,方程式爲:lnP = A - B/T + C*lnT + D*P/T^2
其中A、B、C、D是已知常數,自變量T已知,求P

解答:

Private Sub Command1_Click()
Dim a As Double,b As Double,c As Double,d As Double,t As Double
Dim P As Double,dbl1 As Double,dblDalta As Double
a = Val(Text1)
b = Val(Text2)
c = Val(Text3)
d = Val(Text4)
t = Val(Text5)
P = 2:dbl1 = 1.5
dblDalta = 0.001 '誤差
Do While Abs(P - dbl1) > dblDalta
P = (P + dbl1) / 2
dbl1 = t * t * (Log(P) - a + b / t - c * Log(t)) / d
Debug.Print dbl1
Loop
End Sub
Private Sub Form_Load()
Text1 = 5
Text2 = 208
Text3 = 2
Text4 = 8
Text5 = 9'假設的5個數
End Su

添加新評論

暱稱
郵箱
網站