Tuesday, September 18, 2007

Exercise 1

Visayas State University

City of Baybay, Leyte

Subject : CS141

Description : Computer Programming

Exercise Title : Matrix Applications(1)

Procedure:

  1. Design the form below

  1. The compute button (btnSolve) should multiply matrix1(a) by matrix 2(b) and the Result is displayed in the Product Frame. The details of the computation are likewise displayed on the listbox as reference on how the values were computed. Below is the code used to extract the values from the control array to a two dimensional array.

' this is used to store matrix 1

Dim x(0 To 2, 0 To 2) As Double

' this is used to store matrix 2

Dim y(0 To 2, 0 To 2) As Double

' this is used to store result of matrix1 X matrix2

Dim z(0 To 2, 0 To 2) As Double

Private Sub btnSolve_Click()

' call the procedure getData to extract data from the textboxes control array

getData

lst.Clear

btnCheck.Enabled = True

' call the procedure computeData to do the computation of matrix1 X matrix2 and store it in z 2 dimensional array

computeData

' call the procedure to display the result back to textboxes for the result

ShowResult

End Sub

Sub getData()

Dim i, j

For i = a.LBound To a.UBound

x(i \ 3, i Mod 3) = Val(a(i).Text)

Next

For i = b.LBound To b.UBound

y(i \ 3, i Mod 3) = Val(b(i))

Next

End Sub


  1. The Check Data Stored button should display the value of the matrix depending on which Matrix is selected on the option button. Below displays the values of matrix 2

You can copy paste the given source code above and work on procedures computeData, showResult and Check Data Stored click button. You may add functions necessary to compute and given data. Make sure the names of the controls matches to the ones used in the given source code above.