How to Find the Roots of Quadratic Equation in VB.Net

If you are trying to write code on how to solve quadratic equations, hopefully this tutorial will help you a lot. In this simple program, it will determine the number of roots the equation has and as well as compute the roots. Just follow the steps below to find it out.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application. quadratic1234321

Step 2

Do the form just like this. quadratic54321

Step 3

Double click the button to fire the click event handler of it and create a method for finding the roots of q quadratic equation.
  1. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2. Dim a, b, c As Integer
  3. Dim sqrt, result1, result2 As Double
  4. b = Val(InputBox(“enter value for b”))
  5. a = Val(InputBox(“enter value for a”))
  6. c = Val(InputBox(“enter value for c”))
  7. sqrt = Math.Sqrt(b * b - (4 * a * c))
  8. result1 = (b + s) / (2 * a)
  9. result2 = (-b + s) / (2 * a)
  10. TextBox1.Text = result1
  11. TextBox2.Text = result2
  12. End Sub
For any questions about this article. You can contact me @ Email – [email protected] Mobile No. – 09305235027 – TNT Or feel free to comment below.

Add new comment