write a VB program for addition of two matrice
Answers
Answer:
Private Sub cmdAdd_Click()
Dim i, j, r1, c2 As Integer
Dim a(), b(), c() As Integer
r1 = Val(InputBox(“Enter rows”))
c1 = Val(InputBox(“Enter columns”))
ReDim a(r1, c1)
Text1.Text = “First Matrix is :” & vbNewLine
For i = 1 To r1
For j = 1 To c1
a(i, j) = Val(InputBox(“Enter Elements”))
Text1.Text = Text1.Text & a(i, j) & ” ”
Next
Text1.Text = Text1.Text & vbNewLine
Next
ReDim b(r1, c1)
Text1.Text = Text1.Text & “Second Matrix is :” & vbNewLine
For i = 1 To r1
For j = 1 To c1
b(i, j) = Val(InputBox(“Enter Elements”))
Text1.Text = Text1.Text & b(i, j) & ” ”
Next
Text1.Text = Text1.Text & vbNewLine
Next
ReDim c(r1, c1)
Text1.Text = Text1.Text & “Addition of Two Matrix is :” & vbNewLine
For i = 1 To r1
For j = 1 To c1
c(i, j) = a(i, j) + b(i, j)
Text1.Text = Text1.Text & c(i, j) & ” ”
Next
Text1.Text = Text1.Text & vbNewLine
Next
End Sub
Private Sub cmdClear_Click()
Text1.Text = “”