二元一次方程求解
PrivateSubForm_Click()DimaAsLong,bAsLong,cAsLong,dAsLong,eAsLong,fAsLong,xAsSingle,yA...
Private Sub Form_Click()
Dim a As Long, b As Long, c As Long, d As Long, e As Long, f As Long, x As Single, y As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
e = Val(Text5.Text)
f = Val(Text6.Text)
Do While x>0 and y>0
c = a * x + b * y And f = d * x + e * y
Loop
Print x
Print y
End Sub
-----------------调试,输入a,b,c,d,e,f依次为1,4,13,5,6,28得0,0?方程的解应该是2,3啊,怎么搞的?望那位能人能替我解决这个问题----------还有我要怎么去写x,y的范围为全体实数---------------------谢谢------------------------------------------------------ 展开
Dim a As Long, b As Long, c As Long, d As Long, e As Long, f As Long, x As Single, y As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
e = Val(Text5.Text)
f = Val(Text6.Text)
Do While x>0 and y>0
c = a * x + b * y And f = d * x + e * y
Loop
Print x
Print y
End Sub
-----------------调试,输入a,b,c,d,e,f依次为1,4,13,5,6,28得0,0?方程的解应该是2,3啊,怎么搞的?望那位能人能替我解决这个问题----------还有我要怎么去写x,y的范围为全体实数---------------------谢谢------------------------------------------------------ 展开
2个回答
展开全部
Private Sub Form_Click()
Dim a As Long, b As Long, c As Long, d As Long, e As Long, f As Long, x As double, y As double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
e = Val(Text5.Text)
f = Val(Text6.Text)
if a*c<>b*d then
x=(c*e-b*f)/(a*c-b*d)
y=(a*f-c*d)/(a*c-b*d)
Print x
Print y
elseif a*f=c*d then
msgbox "方程有无数解!"
else
msgbox "方程无解!"
end if
End Sub
Dim a As Long, b As Long, c As Long, d As Long, e As Long, f As Long, x As double, y As double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
e = Val(Text5.Text)
f = Val(Text6.Text)
if a*c<>b*d then
x=(c*e-b*f)/(a*c-b*d)
y=(a*f-c*d)/(a*c-b*d)
Print x
Print y
elseif a*f=c*d then
msgbox "方程有无数解!"
else
msgbox "方程无解!"
end if
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询