- Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x1 As Double
Dim x2 As Double
Dim xmid As Double
Dim fx1 As Double
Dim fx2 As Double
Dim fxmid As Double
Dim root As Double
x1 = Val(TextBox1.Text)
x2 = Val(TextBox2.Text)
xmid = (x1 + x2) / 2
fx1 = (x1 ^ 5) - (3 * (x1 ^ 2)) + 4
fx2 = (x2 ^ 5) - (3 * (x2 ^ 2)) + 4
fxmid = (xmid ^ 5) - (3 * (xmid ^ 2)) + 4
If fx1 * fx2 > 0 Then
MsgBox("Imput Different Range")
End If
If fx1 * fx2 < 0 Then
End If
Do
If fx1 * fxmid < 0 Then
x2 = xmid
ElseIf fx1 * fxmid > 0 Then
x1 = xmid
ElseIf (fx1) * (fxmid) = 0 Then
xmid = root
End If
Exit Do
Loop Until Math.Abs(xmid - x1) < 0.00001
TextBox6.Text = Str(root)
End Sub
I am not sure what I am doing wrong. Any help would be greatly appreciated.


