Using VB to solve a binary complex equation

Source: Internet
Author: User

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 exit toolstripmenuitem_click (byval sender as system. Object, byval e as system. eventargs) handles exit toolstripmenuitem. Click
Dim strexit as string

Strexit = "are you sure you want to stop running? "
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 ("the parameter is normal! ", Vbexclamation," prompt ")
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 ("parameter input failed. Please enter a number! ", Vbexclamation," prompt ")
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 ("calculation error throw, please confirm the parameter is correct! ", Vbexclamation," prompt ")
Lab_x1.text = ""
Lab_x2.text = ""
Lab_y1.text = ""
Lab_y2.text = ""
End try
Else

The call msgbox ("parameter is not normal. ", Vbexclamation," prompt ")

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 ("clear parameters. ", Vbexclamation," prompt ")
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 reset all parameters toolstripmenuitem_click (byval sender as system. Object, byval e as system. eventargs) handles reset all parameters toolstripmenuitem. Click
Clean ()
End sub

Private Sub contact the author toolstripmenuitem_click (byval sender as system. Object, byval e as system. eventargs) handles contact the author toolstripmenuitem. Click
Call msgbox ("author QQ: 389465553, Guang petrochemical short number: 620319", vbexclamation, "tip ")

End sub
End Class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.