excel vba 二分法求解方程的根

请教一下各位大侠看看小弟的错误在那里?
原代码如下,但编译出来后无法运行。。。T T
Function dbfit(xmin As Double, xmax As Double) As Double
Dim a, b, c As Double
Dim xl, xm, xr, ym, yl, yr As Double
xl = xmin
xr = xmax
yl = f(xl)
yr = f(xr)
If yl * yr < 0 Then
  Do While ((xr - xl) > 0.00001)
  xm = (xl + xr) / 2
  ym = f(xm)
  yl = f(xl)
  yr = f(x)
  If ym * yl < 0 Then
  xr = xm
  Else
  xl = xm
  End If
  Loop
  dbfit = xm
Else
End If
End Function

作者: virsure   发布时间: 2011-06-16

要补习一下数学了,二分法的算法。

作者: Tosp2012   发布时间: 2011-06-16