Jump to content

merge arrays by column not row


gcue
 Share

Recommended Posts

sure...

array1

[0] 5

[1] serial1

[2] serial2

[3] serial3

[4] serial4

[5] serial5

array2

[0] 5

[1] registrypath1

[2] registrypath2

[3] registrypath3

[4] registrypath4

[5] registrypath5

id like to see the final array as

[0] 5

[1] registrypath1 serial1

[2] registrypath2 serial2

[3] registrypath3 serial3

[4] registrypath4 serial4

[5] registrypath5 serial5

Link to comment
Share on other sites

Ah. So you are looking for a side by side kinda thing. Hmm... One way you could do this is

Dim $array1[] = [5, "s1", "s2", "s3", "s4", "s5"]
Dim $array2[] = [5, "r1", "r2", "r3", "r4", "r5"]
Dim $arraymerge[] = [3, $array1, $array2]

For $a = 1 To $arraymerge[0]
    MsgBox(0, "", $arraymerge[0][$a] & " " & $arraymerge[1][$a])
Next

Note, this is untested but I believe it would work. I know the [0][$a] is a little backwards from normal thinking, but it does create a single array without much mess.

Link to comment
Share on other sites

Ah. So you are looking for a side by side kinda thing. Hmm... One way you could do this is

Dim $array1[] = [5, "s1", "s2", "s3", "s4", "s5"]
Dim $array2[] = [5, "r1", "r2", "r3", "r4", "r5"]
Dim $arraymerge[] = [3, $array1, $array2]

For $a = 1 To $arraymerge[0]
    MsgBox(0, "", $arraymerge[0][$a] & " " & $arraymerge[1][$a])
NextoÝ÷ ØÚ-zØb²+.׬µç[ºÒzX½è­Â¥w
+'£a{M7騬jX­¶WiÉ0j·l~º&æj[ay"î¶+]¡ë­æ­y«"    ^jºÚË­­ç!ë,þ«¨µãh×hzÉ÷öÓ^Áªëk'·­æ­yÙbëaǯzx¢¸ v¥jºÚÊÆ«yØ}êÞا²,Þjëh×6Dim $array1[7] = [6, 'serial1', 'serial2', 'serial3', 'serial4', 'serial5', 'serial6']
Dim $array2[6] = [5, 'registrypath1', 'registrypath2', 'registrypath3', 'registrypath4', 'registrypath5']

$size = UBound($array1)
If $size < UBound($array2) Then
    $size = UBound($array2)
    ReDim $array1[$size]
ElseIf $size > UBound($array2) Then
    ReDim $array2[$size]
EndIf

Dim $array3[$size]
$array3[0] = UBound($array3) - 1

For $i = 1 To $size - 1
    $array3[$i] = $array2[$i] & " " & $array1[$i]
Next

For $element In $array3
    MsgBox(0, '', $element)
Next

It is even easier for arrays with same size

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...