by Isaac Asampana (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 9th October 2003
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Solve a quadratic equation
API Declarations
Dim x2 As Double
where x1 and x2 are the possible values
Dim x1 As Double
Dim x2 As Double
a = InputBox(" Enter the coefficient of x^2:a")
b = InputBox("Enter the coefficient of x:b")
c = InputBox("Enter the contant of the equation:c")
d = ((b * b) - (4 * a * c))
e = 2 * a
If Val(d) < 0 Then
MsgBox "the equation has no real or equal roots"
End If
If Val(d) >= 0 Then
f = Val(d ^ 0.5)
x1 = (-b + f) / e
x2 = (-b - f) / e
MsgBox " the roots of the equation are:" & Str(x1) & "," & Str(x2)
End If
End Sub