满意答案
add676733
2013.04.01
采纳率:46% 等级:11
已帮助:8098人
Private Sub Command1_Click()
Dim a#, b#, c#, d#, x1#, x2#
a = Val(InputBox("a=", "数据输入框", 1))
b = Val(InputBox("b=", "数据输入框", 2))
c = Val(InputBox("c=", "数据输入框", 1))
If a = 0 Then
If b = 0 Then
If c = 0 Then Print "解得:x有无穷解" Else Print "x无解"
Else
Print "解得:x=" & -c / b
End If
Else
d = b * b - 4 * a * c
If d > 0 Then
x1 = (-b + Sqr(d)) / (2 * a)
x2 = (-b - Sqr(d)) / (2 * a)
Print "解得:x1=" & x1,
Print "x2=" & x2
Else
x1 = -b / (2 * a)
If d = 0 Then Print "解得:x=" & x1
If d < 0 Then
Print "无实根"
End If
End If
End If
End Sub
13分享举报