Write a VB program to display transpose matrix of a given m × n matrix.
Answers
{
Private Sub cmdAdd_Click()
Dim i, j, r1, c2 As Integer
Dim a(), b() 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) & ” ”
{
Text1.Text = Text1.Text & vbNewLine
{
ReDim b(r1, c1)
Text1.Text = Text1.Text & “Transpose of Matrix is :” & vbNewLine
}
}
{
For i = 1 To r1
{
For j = 1 To c1
b(i, j) = a(j, i)
{
Text1.Text = Text1.Text & b(i, j) & ” ”
{
.Text = Text1.Text & vbNewLine
}
}
Private Sub cmdClear_Click()
Text1.Text = “”
}
Private Sub cmdExit_Click()
Unload Me
}