才学VB,写的解一元二次方程
Private Sub Form_Load()App.TaskVisible = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub
Private Sub del_Click()
aa.Text = ""
bb.Text = ""
cc.Text = ""
fc.Caption = "方程为:"
jg.Caption = "结果为:"
End Sub
Private Sub ok_Click()
Dim a As Integer, b As Integer, c As Integer
Dim d As Single, ans As Single
a = Val(aa)
b = Val(bb)
c = Val(cc)
d = b * b - 4 * a * c
If b > 0 Then
fc.Caption = "方程为:" & a & "x^2+" & b & "x+" & c & "=0"
Else
fc.Caption = "方程为:" & a & "x^2" & b & "x+" & c & "=0"
End If
If d < 0 Then
jg.Caption = "结果为: 方程无实根"
Else
jg.Caption = "结果为:" & "X1=" & (-b + Sqr(d)) / 2 * a & " " & "X2=" & (-b - Sqr(d)) / 2 * a
End If
End Sub