Wednesday, December 7, 2011

Simultaneous Equations Solver

t has been sometimes we have not deal with mathematical problems, so why not focus on this subject once again. Actually the thought of programming a mathematical tool came across my mind when my son asked me some questions associated with simultaneous equations. Then It dawned on me that why not I program a simultaneous equation solver so that it can solve my son's problems as well as my problems too. There you are, the program is ready and I am showing the codes here:


Private Sub Command1_Click()
Dim a, b, c, d, m, n As Integer
Dim x, y As Double

a = Val(Txt_a.Text)
b = Val(Txt_b.Text)
m = Val(Txt_m.Text)
c = Val(Txt_c.Text)
d = Val(Txt_d.Text)
n = Val(Txt_n.Text)
x = (b * n - d * m) / (b * c - a * d)
y = (a * n - c * m) / (a * d - b * c)
Lbl_x.Caption = Round(x, 2)
Lbl_y.Caption = Round(y, 2)

End Sub

Private Sub Command2_Click()
Txt_a.Text = ""
Txt_b.Text = ""
Txt_m.Text = ""
Txt_c.Text = ""
Txt_d.Text = ""
Txt_n.Text = ""
Lbl_x.Caption = ""
Lbl_y.Caption = ""

End Sub

1 comment:

Anonymous said...

I'm getting an error "unexpected end of statement" line 2 character 22.