Posted by: Sourav | April 10, 2014

Transpose of a matrix in VB 6.0


Private Sub Command1_Click()

Dim i, j, row1, column1 As Integer
Dim a(), b() As Integer
row1 = Val(InputBox(“Enter rows”))

column1 = Val(InputBox(“Enter columns”))

ReDim a(row1, column1)
Text1.Text = “First Matrix is :” & vbNewLine
For i = 1 To row1
For j = 1 To column1
a(i, j) = Val(InputBox(“Enter Elements”))
Text1.Text = Text1.Text & a(i, j) & ” “
Next
Text1.Text = Text1.Text & vbNewLine
Next
ReDim b(row1, column1)
Text1.Text = Text1.Text & “Transpose of Matrix is : ” & vbNewLine
For i = 1 To row1
For j = 1 To column1
b(i, j) = a(j, i)
Text1.Text = Text1.Text & b(i, j) & ” “
Next
Text1.Text = Text1.Text & vbNewLine
Next
End Sub

Private Sub cmdClear_Click()
Text1.Text = ” “
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: