Array probelm

Results 1 to 2 of 2

Thread: Array probelm

  1. #1
    Join Date
    Dec 1969

    Default Array probelm

    I have a 2-D array populated using .getRows.<BR>This array works perfectly.<BR>I need to put one column of this array into a single array.<BR>I have used the following code...<BR>&#060;%<BR>For x = 0 To iRows<BR>ReDim singArray(x)<BR>singArray(x) = twodArray(2, x)<BR>Next<BR>%&#062;<BR><BR>When i try to print out the contents of this new array, the correct number of rows have been added but they all appear blank except the last.<BR> eg.<BR>0:<BR>1:<BR>2:<BR>3: hello<BR>Num. elements: 4<BR><BR>This is probably some really simple mistake and i would be very grateful if somebody could tell me what i&#039;m doing wrong.<BR> Thanks!

  2. #2
    Join Date
    Dec 1969

    Default You needed ReDim Preserve...

    ...but that is *HORRIBLY* inefficient!<BR><BR>Do it this way, instead:<BR><BR>&#060;%<BR>iRows = UBound( twodArray, 2 )<BR><BR>Dim singArray()<BR>ReDim singArray(iRows)<BR>For x = 0 To iRows<BR> singArray(x) = twodArray(2,x)<BR>Next<BR>%&#062;<BR><BR>Probably 10 to 30 times more efficient than redim&#039;ing each time through the loop.<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