编程一元二次方程的根,输入系数a,b,c,求输入两根x1x2 求高手解答,急用,vb题

2024-11-25 23:37:00
推荐回答(1个)
回答1:

Dim a, b, c
Dim x1, x2
Private Sub Command1_Click()
Cls
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If b * b < 4 * a * c Then
Print "ERROR"
Else
x1 = (-b + Sqr(b * b - 4 * a * c)) / (2 * a)
x2 = (-b - Sqr(b * b - 4 * a * c)) / (2 * a)
x1 = Format(x1, "0.0000")
x2 = Format(x2, "0.0000")
Print x1, x2
End If
End Sub

望采纳。。。。