上眼球胀痛是怎么回事:这个程序错在哪里?谢谢大家啊,提示实时错误6,溢出

来源:百度文库 编辑:高考问答 时间:2024/04/20 21:31:46
Option Explicit
Private Sub Form_Click()
Dim y0 As Single, y1 As Single, y2 As Single
Dim x0 As Single, x1 As Single, x2 As Single
Dim d As Integer

x1 = 1: x2 = 10
Do
y1 = fun1(x1)
y2 = fun1(x2)
x0 = (y1 + y2) / 2
y0 = fun1(x0)
If (y0 * y1 > 0) Then
x1 = x0
Else
x2 = x0
End If
Loop While Abs(y0) > 0.00001
d = MsgBox("x0=", vbOKOnly, Str(x0))

End Sub
Private Function fun1(x As Single) As Single
fun1 = ((x - 5) * x + 16) * x - 90
End Function

无效代码