Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Private Sub Command1_Click()

X1 = Val(Text1)
X2 = Val(Text2)
repeticion = 0
If Combo1 = "(x^2)+2x-5" Then
Do Until repeticion = 300
fx1 = (X1 * X1) + (2 * X1) - 5
Label8 = fx1
fx2 = (X2 * X2) + (2 * X2) - 5
Label9 = fx2
If fx1 * fx2 > 0 Then
Error.Show
Else
If fx1 * fx2 < 0 Then
xr = X2 - ((fx2 * (X1 - X2)) / (fx1 - fx2))
Label10 = xr
fxr = (xr * xr) + (2 * xr) - 5
Label11 = fxr
If fx1 * fxr < 0 Then
X1 = X1
X2 = xr
Else
If fx2 * fxr < 0 Then
X2 = X2
X1 = xr
End If
End If

End If
End If
Text3 = X1
Text4 = X2
repeticion = repeticion + 1
Loop

Else
If Combo1 = "(x^3)+(5x^2)-x-3" Then
Do Until repeticion = 500
fx1 = (X1 * X1 * X1) + (5 * X1 * X1) - X1 - 3
Label8 = fx1
fx2 = (X2 * X2 * X2) + (5 * X2 * X2) - X2 - 3
Label9 = fx2
If fx1 * fx2 > 0 Then
Error.Show
Else
If fx1 * fx2 < 0 Then
xr = X2 - ((fx2 * (X1 - X2)) / (fx1 - fx2))
Label10 = xr
fxr = (xr * xr * xr) + (5 * xr * xr) - xr - 3
Label11 = fxr
If fx1 * fxr < 0 Then
X1 = X1
X2 = xr
Else
If fx2 * fxr < 0 Then
X2 = X2
X1 = xr
End If
End If
End If
End If
Text3 = X1
Text4 = X2
repeticion = repeticion + 1
Loop
End If
End If

End Sub

You might also like