编VB代码
发布网友
发布时间:2022-04-25 00:03
我来回答
共1个回答
热心网友
时间:2023-10-16 13:53
重新写了,你看合适不
'在text1.text输入值22
Private Sub Command1_Click()
Dim x, y
Dim tInt As Single, sumInt As Single
Dim f As Single
tInt = Val(Text1.Text)
x = Array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90)
y = Array(0, 42.04, 83.9, 125.8, 167.5, 209.3, 251.1, 293, 334.9, 377)
i = 0
Do While i <= UBound(x)
f = 1
For m = 0 To UBound(x)
If i <> m Then f = f * (tInt - x(m)) / (x(i) - x(m))
Next
sumInt = sumInt + f * y(i)
i = i + 1
Loop
MsgBox Format(Round(sumInt, 2), "0.00")
End Sub