Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, b, c, dt, s, s1, s2 As String
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
dt = b ^ 2 - 4 * a * c
If dt < 0 Then
TextBox4.Text = "无实根"
Exit Sub
ElseIf (dt = 0) Then
s = (-b + Math.Sqrt(dt)) / (2 * a)
TextBox4.Text = "方程的唯一解是:X= " & s
Exit Sub
Else
s1 = (-b + Math.Sqrt(dt)) / (2 * a)
s2 = (-b - Math.Sqrt(dt)) / (2 * a)
TextBox4.Text = "s1=" & s1 & Chr(13) & Chr(10) & "s2" & s2
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class