Dim sngValA1 As Single 'Declaration for txtValA1~D4
Dim sngValA2 As Single ' " "
Dim sngValB1 As Single ' " "
Dim sngValB2 As Single ' " "
Dim sngAnsOne As Single ' " "
Dim sngAnsTwo As Single ' " "
Dim sngDeterminent2x2 As Single 'Determinent Value for a 2 x 2 Matrix
Dim sngDeterminentDA2x2 As Single 'Determinent Value for A on 2x2 Matrix
Dim sngDeterminentDB2x2 As Single 'Determinent Value for B on 2x2 Matrix
Dim sngSolutionA2x2 As Single 'Solution for A on 2x2 Matrix
Dim sngSolutionB2x2 As Single 'Solution for B on 2x2 Matrix
'Getting users input for the equations trying to solve
Private Sub txtVarAOne_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVarAOne.TextChanged
sngValA1 = Val(txtVarAOne.Text)
End Sub
'Getting users input for the equations trying to solve
Private Sub txtVarATwo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVarATwo.TextChanged
sngValA2 = Val(txtVarATwo.Text)
End Sub
'Getting users input for the equations trying to solve
Private Sub txtVarBOne_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVarBOne.TextChanged
sngValB1 = Val(txtVarBOne.Text)
End Sub
'Getting users input for the equations trying to solve
Private Sub txtVarBTwo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVarBTwo.TextChanged
sngValB2 = Val(txtVarBTwo.Text)
End Sub
'Getting users input for the equations trying to solve
Private Sub txtAnsOne_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAnsOne.TextChanged
sngAnsOne = Val(txtAnsOne.Text)
End Sub
'Getting users input for the equations trying to solve
Private Sub txtAnsTwo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAnsTwo.TextChanged
sngAnsTwo = Val(txtAnsTwo.Text)
End Sub
Private Sub btnSolveEquation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSolveEquation.Click
'Processing the user's input for a 2x2 Matrix Equation and determining the Determinents
sngDeterminent2x2 = (sngValA1 * sngValB2) - (sngValA2 * sngValB1)
sngDeterminentDA2x2 = (sngAnsOne * sngValB2) - (sngAnsTwo * sngValB1)
sngDeterminentDB2x2 = (sngValA1 * sngAnsTwo) - (sngValA2 * sngAnsOne)
'Determining the Solutions for A & B
sngSolutionA2x2 = sngDeterminentDA2x2 / sngDeterminent2x2
sngSolutionB2x2 = sngDeterminentDB2x2 / sngDeterminent2x2
'Displaying the solutions in A & B
lblVarA.Text = sngSolutionA2x2
lblVarB.Text = sngSolutionB2x2
'Displaying the Determinent Value
lblDeterminent.Text = sngDeterminent2x2
'If determinent is equal to zero then there is no solution for an equation
If sngDeterminent2x2 = 0 Then
txtVarAOne.Text = ""
txtVarATwo.Text = ""
txtVarBOne.Text = ""
txtVarBTwo.Text = ""
txtAnsOne.Text = ""
txtAnsTwo.Text = ""
lblVarA.Text = ""
lblVarB.Text = ""
lblErrorDisp1.Text = "Determinent = 0 ~ No Solution"
End If
End Sub
Private Sub btnClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearAll.Click
'Clears all fields when clicked
txtVarAOne.Text = "0"
txtVarATwo.Text = "0"
txtVarBOne.Text = "0"
txtVarBTwo.Text = "0"
txtAnsOne.Text = "0"
txtAnsTwo.Text = "0"
lblVarA.Text = ""
lblVarB.Text = ""
lblErrorDisp1.Text = ""
lblDeterminent.Text = ""
End Sub
End Class