网络程序--VB
要求:输入一元二次方程ax^2+bx+c=0的系数abc,计算并输出一元二次方程的两个根x1,x2PrivateSubCommand1_Click()Dima%,b%,c...
要求:输入一元二次方程ax^2+bx+c=0的系数abc,计算并输出一元二次方程的两个根x1,x2
Private Sub Command1_Click()
Dim a%, b%, c%, x1!, x2!
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
a (x1) ^ 2 + b(x1) + c = 0
a (x2) ^ 2 + b(x2) + c = 0
x1 = Val(Text4.Text)
x2 = Val(Text5.Text)
End Sub
Private Sub Command2_Click()
End
End Sub 展开
Private Sub Command1_Click()
Dim a%, b%, c%, x1!, x2!
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
a (x1) ^ 2 + b(x1) + c = 0
a (x2) ^ 2 + b(x2) + c = 0
x1 = Val(Text4.Text)
x2 = Val(Text5.Text)
End Sub
Private Sub Command2_Click()
End
End Sub 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim a, b, c ,x1 ,x2 as double
dim d as double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d=b^2-4*a*c
if d<0 then
msgbox "此方程无解!"
exit sub
else
x1=(b*(-1)+spr(d))/(2*a)
x2=(b*(-1)-spr(d))/(2*a)
text4.text=x1
text5.text=x2
'text4和text5为计算结果
end if
End Sub
Private Sub Command2_Click()
End
End Sub
Dim a, b, c ,x1 ,x2 as double
dim d as double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d=b^2-4*a*c
if d<0 then
msgbox "此方程无解!"
exit sub
else
x1=(b*(-1)+spr(d))/(2*a)
x2=(b*(-1)-spr(d))/(2*a)
text4.text=x1
text5.text=x2
'text4和text5为计算结果
end if
End Sub
Private Sub Command2_Click()
End
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询