作业帮 > 综合 > 作业

VB编程,一元二次方程a*x^2+b*x+c=0的根

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/11 10:07:21
VB编程,一元二次方程a*x^2+b*x+c=0的根
Dim a As Double
Dim b As Double
Dim c As Double
Dim delta As Double
Dim x1 As Double
Dim x2 As Double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
delta = b * b - a * a * c
If delta > 0 Then
x1 = (-b + Sqr(delta)) / (2 * a)
x2 = (-b - Sqr(delta)) / (2 * a)
MsgBox "x1=" + Str(x1) + vbCrLf + "x2=" + Str(x2)
ElseIf delta = 0 Then
MsgBox "x1=x2=" + Str((-b) / (2 * a))
Else
MsgBox "没有实数解"
End If
这个编程有错没
VB编程,一元二次方程a*x^2+b*x+c=0的根
有错:
1)delta=b*b-4*a*c
2)要判断a是否为0