We help IT Professionals succeed at work.
Get Started

add to multidimensional array

dcass
dcass asked
on
473 Views
Last Modified: 2012-06-21
I need to add one array to another (or add them both to a new one, but MSDN says redim is not needed but I get an error when I try to add to the next available index.
I tried dim and redim - still error - subscript out of range on arrResultsx(x,ctrx).  I also tried without the internal x loop.
SQL = "SELECT * FROM T1News where ..."
      SQL_Rs.open SQL,SQL_Cn,3
       	IF NOT(SQL_Rs.EOF) THEN
			arrResultsx = SQL_Rs.getrows
		    ctrx = ubound(arrResultsx,2)
		END IF
      	SQL_Rs.close
ctrx2=0
      SQL = "SELECT * FROM T1News where ..."
      SQL_Rs.open SQL,SQL_Cn,3
       	IF NOT(SQL_Rs.EOF) THEN
			arrResultsx2 = SQL_Rs.getrows
		    ctrx2 = ubound(arrResultsx2,2)
		END IF
      	SQL_Rs.close
      	
    ctrx = ctrx + 1
'    ctr = ctrx+ctrx2
'    ReDim arrResultsx(ctr)
'    %><%=arrResultsx(x,ctr)%><Br><%
    if ctrx2 > 0 then      ' if anything in 2nd array, then proceed
      for i = 0 to ctrx2
        for x = 0 to 30
'          redim preserve arrResultsx(x,ctrx)
          arrResultsx(x,ctrx) = arrResultsx2(x,i) ' also tried arrResultsx(ctrx)=arrResultsx2(i)
          ctrx = ctrx + 1
        next
      next
    end if

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE