Quadratic Equation Program In Vb.net
Dreams soft software programming projects Quadratic Formula/ Quadratic Equation Visual Basic, VB.net. Write a VB program to find the roots of quadratic equation. Write a VB program to find the roots of quadratic equation. ” jude says: March 30, 2016 at 4:43 am.
Step Open a new Visual Basic program. Double-click the 'Button' tool to add Button1 to the form. Double-click the 'Label' tool twice to add Label1 and Label2 to the form.
Truett Mcconnell Nursing Programdownload Free Software Programs Online. Step Double-click 'Button1' on the form to open the code window. Type the following code: Dim a As Decimal = InputBox('Enter A: ') Dim b As Decimal = InputBox('Enter B: ') Dim c As Decimal = InputBox('Enter C: ') Quadratic(a, b, c) The first three lines prompt the user for the values of the constants. It then calls a sub called 'Quadratic' and passes the constants as arguments to it. Step Insert the cursor outside of the Button1 sub. Control4 Composer Pro Crack more.
Type the following code: Private Sub Quadratic(ByVal a As Decimal, ByVal b As Decimal, ByVal c As Decimal) Dim roots(1) As String Dim x1, x2, disc As Decimal disc = b ^ 2 - 4 a c The first line creates the Quadratic sub and accepts three arguments. It then defines an array with two items for the two roots. It then creates three decimal variables and assigns the value of the discriminant, which determines the number of roots the quadratic equation has. Step Type the following code. If disc >= 0 Then x1 = (-b + Math.Sqrt(disc)) / (2 a) x2 = (-b - Math.Sqrt(disc)) / (2 a) roots(0) = x1.ToString roots(1) = x2.ToString Else roots(0) = '(-' & b.ToString & '+Sqrt(' & disc.ToString & '))/(2 ' & a.ToString & ')' roots(1) = '(-' & b.ToString & '-Sqrt(' & disc.ToString & '))/(2' & a.ToString & ')' End If The 'if' function checks to see if the value of the discriminant is greater than or equal to zero, which means the equation has one or two roots. It then solves for x.
If the discriminant is less than zero, the equation has no real roots and the 'else' portion executes, which displays the complex roots equations. Step Type the following code: Label1.Text = roots(0) Label2.Text = roots(1) End Sub These lines of code simply display the roots on the labels and then close the Quadratic sub's code block. Step Save the Visual Basic program. Press 'F5' to run it.
Quadratic Functions Graph Plotter This is a program that can plot graphs for quadratic functions. The formula of a quadratic equation is f(x)= ax 2+bx+c, where a, b and c are constant. This program employs a picture box as the plot area and three text boxes to obtain the values of the coefficients a, b, c of the quadratic equation from the users. We also need to modify the scale factor in the properties windows of the picture box. We are using a scale of 0.5 cm to represent 1 unit.
Besides, we need to make some transformation as the coordinates in VB start from top left but we want it to start from the middle. We can use the Pset method to draw the graph using a very small increment.
Pset is a method that draws a dot on the screen, the syntax is Pset(x,y), color Where (x,y) is the coordinates of the dot and color is the color of the dot. Using the For Next loop together with Pset, we can draw a line on the screen. The Interface The Code Private Sub cmd_draw_Click() Dim a, b, c As Integer Dim w, v As Single a = Val(txt_a.Text) b = Val(txt_b.Text) c = Val(txt_c.Text) ' Using a scale of 0.5 cm to represent i unit to draw the graph ' Need to make some transformation as the coordinates in VB start from top left For w = 0 To 10 Step 0.001 v = a * (5 - w) ^ 2 - b * (5 - w) + c pic_graph.PSet (w, 5 - v) Next w End Sub Private Sub Command1_Click() pic_graph.Cls txt_a.Text = ' txt_b.Text = ' txt_c.Text = ' End Sub.