Posted by: Sourav | April 11, 2014

Joining two 2d array side by side in VB 6.0


Private Sub Command1_Click()
Dim firstarray(2, 2) As String
Dim secondarray(2, 2) As String
Dim mergedarray() As String

firstarray(0, 0) = “India”
firstarray(0, 1) = “Pakisthan”
firstarray(1, 0) = “Usa”
firstarray(1, 1) = “Bangla”
secondarray(0, 0) = “Del”
secondarray(0, 1) = “Islamabad”
secondarray(1, 0) = “DC”
secondarray(1, 1) = “Dhaka”

Dim i As Integer
Dim c As Integer
Dim l As Integer
Dim p As Integer
Dim counter, counter1 As Integer
counter = 0
counter1 = 0
ReDim mergedarray(0 To (UBound(firstarray, 2) + UBound(secondarray, 2)), 0 To 1) As String

‘Print UBound(firstarray, 2)

For i = 0 To (UBound(firstarray) – 1)

For j = 0 To (UBound(firstarray) – 1)

 

mergedarray(counter, 0) = firstarray(i, j)
counter = counter + 1

Next j

Next i
counter = 0
For i = 0 To (UBound(firstarray) – 1)

For j = 0 To (UBound(firstarray) – 1)

 

mergedarray(counter, 1) = secondarray(i, j)
counter = counter + 1

Next j

Next i

For i = 0 To UBound(mergedarray) – 1
For j = 0 To 1
Text1.Text = Text1.Text + ” ” + mergedarray(i, j)
Next j
Text1.Text = Text1.Text + vbCrLf

Next i

 

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: