0% found this document useful (0 votes)
27 views

Public Class Private Sub As Object As Handles Dim As String As String Dim As String As String Dim As String As String

The document contains code that calculates the solutions to a quadratic equation. It takes coefficients a, b, and c from text boxes, calculates the discriminant d, and determines the number and type of solutions based on d. If d is positive, it calculates two real solutions. If d is zero, it calculates one repeated real solution. If d is negative, it calculates two complex solutions with an "i" term. The solutions are displayed in two output text boxes, and a message is shown for complex solutions.

Uploaded by

HamiltonMosquera
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Public Class Private Sub As Object As Handles Dim As String As String Dim As String As String Dim As String As String

The document contains code that calculates the solutions to a quadratic equation. It takes coefficients a, b, and c from text boxes, calculates the discriminant d, and determines the number and type of solutions based on d. If d is positive, it calculates two real solutions. If d is zero, it calculates one repeated real solution. If d is negative, it calculates two complex solutions with an "i" term. The solutions are displayed in two output text boxes, and a message is shown for complex solutions.

Uploaded by

HamiltonMosquera
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Dim a As String, b As String
Dim c As String, d As String
Dim R1 As String, R2 As String
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = (b ^ 2) - (4 * a * c)
If d > 0 Then
End If
R1 = (-b + Math.Sqrt(d)) / (2 * a)
R2 = (-b - Math.Sqrt(d)) / (2 * a)
TextBox4.Text = R1
TextBox5.Text = R2
If d = 0 Then
R1 = -(b / (2 * a))
TextBox4.Text = R1
End If
If d < 0 Then
R1 = (-(b / (2 * a)) + ((Math.Sqrt(d * -1)) / (2 * a))) & "i"
R2 = (-(b / (2 * a)) - ((Math.Sqrt(d * -1)) / (2 * a))) & "i"
TextBox4.Text = R1
TextBox5.Text = R2
MsgBox("Las races son complejas")
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


End
End Sub
End Class

You might also like