Function PosFal(Tol As Double, A As Double, B As Double) As Double Dim Indice As Long Dim Error, C As Double Indice = 0 Error = 100 Do While Error > Tol If Indice > 100000 Then Exit Do End If C = B - fu(B) * (B - A) / (fu(B) - fu(A)) If Abs(fu(C)) < Tol Then PosFal = C Error = Abs(fu(C)) ElseIf fu(A) * fu(C) < 0 Then B = C ElseIf fu(C) * fu(B) < 0 Then A = C Else MsgBox "El intervalo no es correcto" Exit Do End If Indice = Indice + 1 Loop MsgBox "Número de iteraciones es " + Str(Indice) End Function