david blaine
03-22-2008, 12:27 PM
I guess it will help somebody? idc
date Thu, Jan 5, 2006 at 2:29 PM
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
Dim a, b, c As Double
a = InputBox("What is the a value?", "A:")
b = InputBox("What is the b value?", "B:")
c = InputBox("What is the c value?", "C:")
Quadratic(a, b, c)
End Sub
Sub Quadratic(ByRef a As Double, ByRef b As Double, ByRef c As Double)
'Determine how many real solutions
If (a = 0) Then
MsgBox("A cannot equal zero")
Else
a = a
End If
If b ^ 2 - (4 * a * c) > 0 Then
txtType.Text = "2 Real Roots"
ElseIf b ^ 2 - (4 * a * c) = 0 Then
txtType.Text = "1 Real Root"
Else
txtType.Text = "0 Roots"
End If
'Now we find the solutions
txtQuad.Text = CStr("The Roots are " & (QuadNeg(a, b, c) & " and " & QuadPos(a, b, c)))
End Sub
Function QuadNeg(ByRef a As Double, ByRef b As Double, ByRef c As Double)
Return (-b - Math.Sqrt(b ^ 2 - 4 * a * c)) / (2 * a)
End Function
Function QuadPos(ByRef a As Double, ByRef b As Double, ByRef c As Double)
Return (-b + Math.Sqrt(b ^ 2 - 4 * a * c)) / (2 * a)
End Function
date Thu, Jan 5, 2006 at 2:29 PM
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
Dim a, b, c As Double
a = InputBox("What is the a value?", "A:")
b = InputBox("What is the b value?", "B:")
c = InputBox("What is the c value?", "C:")
Quadratic(a, b, c)
End Sub
Sub Quadratic(ByRef a As Double, ByRef b As Double, ByRef c As Double)
'Determine how many real solutions
If (a = 0) Then
MsgBox("A cannot equal zero")
Else
a = a
End If
If b ^ 2 - (4 * a * c) > 0 Then
txtType.Text = "2 Real Roots"
ElseIf b ^ 2 - (4 * a * c) = 0 Then
txtType.Text = "1 Real Root"
Else
txtType.Text = "0 Roots"
End If
'Now we find the solutions
txtQuad.Text = CStr("The Roots are " & (QuadNeg(a, b, c) & " and " & QuadPos(a, b, c)))
End Sub
Function QuadNeg(ByRef a As Double, ByRef b As Double, ByRef c As Double)
Return (-b - Math.Sqrt(b ^ 2 - 4 * a * c)) / (2 * a)
End Function
Function QuadPos(ByRef a As Double, ByRef b As Double, ByRef c As Double)
Return (-b + Math.Sqrt(b ^ 2 - 4 * a * c)) / (2 * a)
End Function