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

Submitted by: 
Visitors have accessed this post 870 times.

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.

Step 2

Do the form just like this.

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

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.