Hola amigos soy nuevo y tengo este algoritmo de biseccion y quiero colocar dos edit para a y b...pero no se como me ayudan porq alli estan como constantes..... y le e jalado y nada me salen muchos errores gracias por todo..asi sea por leerlo...cualquier respuesta
jairj02@yahoo.es porfavor
Option Explicit
Dim a, b As Double
Dim TOL As Double
Dim res As Double
Dim N As Integer
Function f(ByVal x As Double) As Double
f = Cos(x) - x
End Function
Sub Biseccion(ByVal a As Double, ByVal b As Double, ByVal TOL As Double, _
ByVal N As Integer, ByRef res As Double)
Dim p, fa, fp As Double
Dim i As Integer
Dim Flag As Boolean
i = 1
fa = f(a)
Flag = False
Do While (i <= N) And Not (Flag)
p = a + (b - a) / 2
fp = f(p)
If fp = 0 Or (b - a) / 2 < TOL Then
res = p
Flag = True
End If
i = i + 1
If fa * fp > 0 Then
a = p
fa = fp
Else
b = p
End If
Loop
If Not Flag Then
MsgBox "El método fracaso por exceder el numero de iteraciones", vbExclamation, "Bisección"
End If
End Sub
Private Sub cmdEjecutar_Click()
Call Biseccion(a, b, TOL, N, res)
txtr.Text = res
End Sub
Private Sub Form_Load()
a = 0.5
b = 0.785398163
TOL = 0.000001
N = 20
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub