Private Sub CmdSolve_Click()
Dim a As Single: a = Val(Text1.Text)
Dim b As Single: b = Val(Text2.Text)
Dim c As Single: c = Val(Text3.Text)
Dim p As Single: p = b ^ 2 - 4 * a * c
Dim x1 As Single, X2 As Single, e As Single, f As Single
If a = 0 Then
Text4.Text = "无解"
Text5.Text = "无解"
Else
If p >= 0 Then
x1 = (-b + Sqr(p)) / (2 * a): X2 = (-b - Sqr(p)) / (2 * a): Text4.Text = x1: Text5.Text = X2
Else
e = -b / (2 * a): f = (Sqr(-p)) / (2 * a): Text4.Text = Str(e) & "+" & Str(f) & "i": Text5.Text = Str(e) & "+" & Str(f) & "i"
End If
End If
End Sub