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.
Open Microsoft Visual Studio 2015 and create a new windows form application.
Do the form just like this.
Double click the button to fire the
click event handler of it and create a method for finding the roots of q quadratic equation.
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim a, b, c As Integer
- Dim sqrt, result1, result2 As Double
- b = Val(InputBox(“enter value for b”))
- a = Val(InputBox(“enter value for a”))
- c = Val(InputBox(“enter value for c”))
- sqrt = Math.Sqrt(b * b - (4 * a * c))
- result1 = (b + s) / (2 * a)
- result2 = (-b + s) / (2 * a)
- TextBox1.Text = result1
- TextBox2.Text = result2
- 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.