VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Solve a quadratic equation

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

Rate Solve a quadratic equation



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



Download this snippet    Add to My Saved Code

Solve a quadratic equation Comments

No comments have been posted about Solve a quadratic equation. Why not be the first to post a comment about Solve a quadratic equation.

Post your comment

Subject:
Message:
0/1000 characters