by P N Bendigeri (2 Submissions)
Category: Math/Dates
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 2nd January 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Finding real roots of quadratic equation.
Private Type QuaEqu
x1 As Double
x2 As Double
End Type
Dim d As Double
Private Function RootsOfQuaEqu(ByVal a As Single, ByVal b As Single, ByVal c As Single) As QuaEqu
d = (b * b - 4 * a * c)
If d < 0 Then
MsgBox "Roots are Imaginary"
Exit Function
End If
RootsOfQuaEqu.x1 = (-b + Sqr(d)) / (2 * a)
RootsOfQuaEqu.x2 = (-b - Sqr(d)) / (2 * a)
End Function