关于VB迭代法的用法,帮忙用VB写下代码。。

关于VB迭代法的用法,帮忙用VB写下代码。。,第1张

Private Sub Form_Click()

Form1.AutoRedraw = True

Cls

Dim P15 As Single, P20 As Single, A As Single, Tt As Single

Dim T As Single, P151 As Single, I As Integer

Dim E As Single

E = Exp(1)

T = Val(InputBox("t=", "输入", 1))

P20 = Val(InputBox("p20=", "输入", 30))

Tt = T

P15 = P20

Print "t="T, "p20="P20

I = 0

Do

I = I + 1

P151 = P15

A = 186.9696 / P15 ^ 2 + 0.4862 / P15

P15 = P20 / E ^ -A * Tt * (1 + 0.8 * A * Tt)

Print I, "p151="P151, "p15="P15

Loop While Abs(P15 - P151) >= 0.0005

Print "最后结果为:p15="P15

End Sub

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 Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7769331.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-09
下一篇 2023-04-09

发表评论

登录后才能评论

评论列表(0条)

保存