求用VB编辑一个计算二元一次方程组的程序要完善的,不能有程序崩溃,比如输入数据时输入的不是数字而是字母就会崩溃
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 15:15:40
求用VB编辑一个计算二元一次方程组的程序要完善的,不能有程序崩溃,比如输入数据时输入的不是数字而是字母就会崩溃
求用VB编辑一个计算二元一次方程组的程序
要完善的,不能有程序崩溃,比如输入数据时输入的不是数字而是字母就会崩溃
求用VB编辑一个计算二元一次方程组的程序要完善的,不能有程序崩溃,比如输入数据时输入的不是数字而是字母就会崩溃
主程序代码就是这样,如果要详细的,留下邮箱我给你发过来
-----------------------------------------------------------------------
Private Sub Command1_Click()
If IsNumeric(Text3.Text) And IsNumeric(Text4.Text) And IsNumeric(Text5.Text) And IsNumeric(Text6.Text) And IsNumeric(Text7.Text) And IsNumeric(Text8.Text) Then
a1 = Val(Text3.Text)
a2 = Val(Text4.Text)
b1 = Val(Text5.Text)
b2 = Val(Text6.Text)
c1 = Val(Text7.Text)
c2 = Val(Text8.Text)
Else
MsgBox "未完整输入数据无法运算,请输入数据."
a1 = Val(InputBox("a1 = ", "输入a1值", , 20))
b1 = Val(InputBox("b1 = ", "输入b1值", , 20))
c1 = Val(InputBox("c1 = ", "输入c1值", , 20))
a2 = Val(InputBox("a2 = ", "输入a2值", , 20))
b2 = Val(InputBox("b2 = ", "输入b2值", , 20))
c2 = Val(InputBox("c2 = ", "输入c2值", , 20))
End If
If IsNumeric(a1) And IsNumeric(b1) And IsNumeric(c1) And IsNumeric(a2) And IsNumeric(b2) And IsNumeric(c2) Then
Y1 = a1 * c2 - a2 * c1
X1 = b2 * c1 - b1 * c2
Text3.Text = a1
Text4.Text = a2
Text5.Text = b1
Text6.Text = b2
Text7.Text = c1
Text8.Text = c2
e = a1 * b2 - a2 * b1 + 1
Else
MsgBox " 字符无效 无法求解."
Text1.Text = "×"
Text2.Text = "×"
End If
If e 1 And IsNumeric(a1) And IsNumeric(b1) And IsNumeric(c1) And IsNumeric(a2) And IsNumeric(b2) And IsNumeric(c2) Then
y = Y1 / (e - 1)
x = X1 / (e - 1)
Text1.Text = x
Text2.Text = y
ElseIf e = 1 Then
MsgBox "除数为零/系数相同 无法求解"
Text1.Text = "×"
Text2.Text = "×"
End If
End Sub