这是我写一个解方程的程序,运行后提示“子程序或函数未定义”,是哪儿错了呢?谢谢!
Private Sub Command1_Click()
Dim a, b, c, x1, x2, i, t As Currency
a = Val(Text1.Text): b = Val(Text2.Text): c = Val(Text3.Text)
If Abs(a)0.0001) Then
MsgBox ("该方程无解")
End If
If Abs(b) > 0.0001 Then
x1 = -c / b
MsgBox ("该方程为一次方程" & ch(10) & "X=" & x1)
End If
Else
t = b ^ 2 - 4 * a * c
If Abs(t) <= 0.0001 Then
MsgBox ("该二次方程在实数范围内无解")
Else
x1 = (-b + t ^ 0.5) / (2 * a)
x2 = (-b - t ^ 0.5) / (2 * a)
End If
End If
End Sub
p.s.我是初学的,望多多指教!!
|