merging arrays

Results 1 to 2 of 2

Thread: merging arrays

  1. #1
    Join Date
    Dec 1969

    Default merging arrays

    I have 2 arrays, created from 2 separate database calls, each with the same number of rows. How can add the 2 together, creating extra column(s)?<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Well, the best solution...

    ...would be to *NOT* have 2 separate database calls! Why do you do that? Why not one DB call, one RecordSet, and then one array?<BR><BR>But if you *must*:<BR><BR>&#060;%<BR>ar1 = RS1.GetRows( )<BR>ar2 = RS2.GetRows( )<BR><BR>If UBound(ar1,2) &#060;&#062; UBound(ar2,2) Then<BR>&nbsp; &nbsp; Response.Write "You fibbed about them being same size."<BR>&nbsp; &nbsp; Response.End<BR>End If<BR><BR>armax = UBound(ar1,2)<BR>col1max = UBound(ar1,1)<BR>col2max = UBound(ar2,1)<BR><BR>Dim merge()<BR>ReDim merge( col1max + col2max + 1, armax )<BR><BR>For row = 0 To armax<BR>&nbsp; &nbsp; For col = 0 to col1max<BR>&nbsp; &nbsp; &nbsp; &nbsp; merge( col, row ) = ar1( col, row )<BR>&nbsp; &nbsp; Next<BR>&nbsp; &nbsp; For col = 0 to col2max<BR>&nbsp; &nbsp; &nbsp; &nbsp; merge( col1max+col+1, row ) = ar2( col, row )<BR>&nbsp; &nbsp; Next<BR>Next<BR>...<BR>%&#062;<BR><BR>Untested, but I think that does it.<BR><BR>Wouldn&#039;t you *really* rather make just one query, get one recordset, and one array, to begin with??? It would be *TONS* faster!<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts