Vb
程序解一元二次方程
以下是程序代码
需要的控件
7
个
label
3
个
text
一个
command
Private Sub Command1_Click()
Dim a, b, c, d, e, f As String
a = Text1.Text
b = Text2.Text
c = Text3.Text
d = b * b - 4 * a * c
If d > 0 Then
e = (-b + Sqr(d)) / 2 * a
Label6.Caption = e
f = (-b - Sqr(d)) / 2 * a
Label7.Caption = f
End If
If d = 0 Then
e = (-b + Sqr(d)) / 2 * a
Label6.Caption = e
f = (-b - Sqr(d)) / 2 * a
Label7.Caption = f
End If
If d
Label6.Caption = "
无解
"
Label7.Caption = "
无解
"
End If
End Sub
Private Sub Form_Load()
Label1.Caption = "
请输入二次项系数
"
Label2.Caption = "
请输入一次项系数
"
Label3.Caption = "
请输入常数项
"
Label4.Caption = "X1="
Label5.Caption = "X2="
End Sub