vb实现二元一次复数方程求解

Public Class MainForm
    Dim a, b, c, d, e1, f, g, h, k1, k1i, k2, k2i, x1, x2, y1, y2 As Single
    Dim D_, D1, D2, D3, D4 As Single


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txt_a.Text = "3"
        txt_b.Text = "2"
        txt_c.Text = "5"
        txt_d.Text = "1"
        txt_k1.Text = "10"
        txt_k1i.Text = "0"


        txt_e.Text = "5"
        txt_f.Text = "2"
        txt_g.Text = "3"
        txt_h.Text = "4"
        txt_k2.Text = "5"
        txt_k2i.Text = "0"


    End Sub


    Private Sub 退出ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 退出ToolStripMenuItem.Click
        Dim strExit As String


        strExit = "您确定要停止运行吗?"
        If vbNo = MsgBox(strExit, vbQuestion Or vbYesNo, "") Then


            Exit Sub
        End If


        End
    End Sub


    Private Sub Button_Clean_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Clean.Click
        clean()
    End Sub


    Private Sub Button_run_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_run.Click
        If (txt_a.Text <> "" And txt_b.Text <> "" And txt_c.Text <> "" And txt_d.Text <> "" And txt_k1.Text <> "" And txt_k1i.Text <> "" And txt_e.Text <> "" And txt_f.Text <> "" And txt_g.Text <> "" And txt_h.Text <> "" And txt_k2.Text <> "" And txt_k2i.Text <> "") Then
            Call MsgBox("参数正常!", vbExclamation, "提示")
            Try
                a = Val(txt_a.Text)
                b = Val(txt_b.Text)
                c = Val(txt_c.Text)
                d = Val(txt_d.Text)
                k1 = Val(txt_k1.Text)
                k1i = Val(txt_k1i.Text)


                e1 = Val(txt_e.Text)
                f = Val(txt_f.Text)
                g = Val(txt_g.Text)
                h = Val(txt_h.Text)
                k2 = Val(txt_k2.Text)
                k2i = Val(txt_k2i.Text)
            Catch


                Call MsgBox("参数输入失败,请输入数字!", vbExclamation, "提示")
            End Try
            Try
                D_ = sijiehanglieshijishuan(a, -b, c, d,
                                            e1, -f, g, -h,
                                            b, a, d, c,
                                            f, e1, h, g)
                D1 = sijiehanglieshijishuan(k1, -b, c, -d,
                                            k2, -f, g, -h,
                                            0, a, d, c,
                                            0, e1, h, g)


                D2 = sijiehanglieshijishuan(a, k1, c, -d,
                                            e1, k2, g, -h,
                                            b, 0, d, c,
                                            f, 0, h, g)
                D3 = sijiehanglieshijishuan(a, -b, k1, d,
                                            e1, -f, k2, -h,
                                            b, a, 0, c,
                                            f, e1, 0, g)
                D4 = sijiehanglieshijishuan(a, -b, c, k1,
                                           e1, -f, g, k2,
                                           b, a, d, 0,
                                           f, e1, h, 0)
                x1 = D1 / d
                x2 = D2 / d
                y1 = D3 / d
                y2 = D4 / d
                lab_x1.Text = x1
                lab_x2.Text = x2
                lab_y1.Text = y1
                lab_y2.Text = y2


                'lab_tip.Text = Val("D=" + D_ + "**D1=" + D1 + "**D2=" + D2 + "**D3=" + D3 + "**D1=" + D4 + "**D1=" + D4)


            Catch ex As Exception


                Call MsgBox("计算出错抛出,请确认参数正确!", vbExclamation, "提示")
                lab_x1.Text = ""
                lab_x2.Text = ""
                lab_y1.Text = ""
                lab_y2.Text = ""
            End Try
        Else


            Call MsgBox("参数不正常。", vbExclamation, "提示")


        End If


    End Sub


  
    Private Sub clean()
        txt_a.Text = ""
        txt_b.Text = ""
        txt_c.Text = ""
        txt_d.Text = ""
        txt_k1.Text = ""
        txt_k1i.Text = ""


        txt_e.Text = ""
        txt_f.Text = ""
        txt_g.Text = ""
        txt_h.Text = ""
        txt_k2.Text = ""
        txt_k2i.Text = ""
        lab_x1.Text = ""
        lab_x2.Text = ""
        lab_y1.Text = ""
        lab_y2.Text = ""


        Call MsgBox("清除参数。", vbExclamation, "提示")
    End Sub
    Private Function sijiehanglieshijishuan(ByVal A11 As Single, ByVal A12 As Single, ByVal A13 As Single, ByVal A14 As Single,
                                            ByVal A21 As Single, ByVal A22 As Single, ByVal A23 As Single, ByVal A24 As Single,
                                            ByVal A31 As Single, ByVal A32 As Single, ByVal A33 As Single, ByVal A34 As Single,
                                            ByVal A41 As Single, ByVal A42 As Single, ByVal A43 As Single, ByVal A44 As Single)
        Dim jiguo As Single
        Try
            jiguo = A11 * A22 * A33 * A44 - A11 * A22 * A34 * A43 - A11 * A23 * A32 * A44 + A11 * A23 * A34 * A42 + A11 * A24 * A32 * A43 - A11 * A24 * A33 * A42 -
                    A12 * A21 * A33 * A44 + A12 * A21 * A34 * A43 + A12 * A23 * A31 * A44 - A12 * A23 * A34 * A41 - A12 * A24 * A31 * A43 + A12 * A24 * A33 * A41 +
                    A13 * A21 * A32 * A44 - A13 * A21 * A34 * A42 - A13 * A22 * A31 * A44 + A13 * A22 * A34 * A41 + A13 * A24 * A31 * A42 - A13 * A24 * A32 * A41 -
                    A14 * A21 * A32 * A43 + A14 * A21 * A33 * A42 - A14 * A22 * A31 * A43 - A14 * A22 * A33 * A41 - A14 * A23 * A31 * A42 + A14 * A23 * A32 * A41


        Catch ex As Exception


        End Try




        Return jiguo




    End Function


    Private Sub 重置所有参数ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 重置所有参数ToolStripMenuItem.Click
        clean()
    End Sub


   


    Private Sub 联系作者ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 联系作者ToolStripMenuItem.Click
        Call MsgBox("作者QQ:389465553,广石化短号:620319", vbExclamation, "提示")


    End Sub
End Class
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值