求一元二次方程的根,运行时提示实时错误6溢出,请高手指教,非常感谢了,在线等……
Private Sub Command1_Click()
Dim pbs As Double
pbs = b * b - 4 * a * c
If pbs > 0 Then
pbs = Sqr(pbs)
Text4 = Format((-b + pbs) / 2 / a, "0.00")
Text5 = Format((-b - pbs) / 2 / a, "0.00")
ElseIf pbs = 0 Then
Text4 = Format(-b / 2 / a, "0.00")
Text5 = Format(-b / 2 / a, "0.00")
Else
pbs = Sqr(-pbs)
Text4 = Format((-b + pbs) / 2 / a, "0.00") + "i"
Text5 = Format((-b - pbs) / 2 / a, "0.00") + "-i"
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text1.SetFocus
End Sub
Private Sub Text1_Change()
If Text1"" And Not IsNumeric(Text1) Then
Text1 = ""
Text1.SetFocus
Else
a = Text1
End If
End Sub
Private Sub Text2_Change()
If Text2"" And Not IsNumeric(Text2) Then
Text2 = ""
Text2.SetFocus
Else
b = Text2
End If
End Sub
Private Sub Text3_Change()
If Text3"" And Not IsNumeric(Text3) Then
Text3 = ""
Text3.SetFocus
Else
c = Text3
End If
End Sub
|