Array vs Array: Who knocks out whom!

Results 1 to 2 of 2

Thread: Array vs Array: Who knocks out whom!

  1. #1
    Join Date
    Dec 1969

    Default Array vs Array: Who knocks out whom!

    Hi All,<BR><BR> I have a curious problem and suspect I&#039m missing something. As is evidenced by the follows:<BR><BR> I have two arrays.<BR><BR> Array1(20)<BR> Array2(3)<BR><BR> I want to remove items which don&#039t exist in Array1 using Array2 as the key, in a loop,!???twice???!. (Might be way off track here)<BR><BR> for j = 0 to uBound(Array1)<BR> for i = 0 to uBound(Array2)<BR> if Array2(i) &#060;&#062; Array1(j)<BR> //remove item from array1<BR> i = i + 1<BR> next<BR> j = j + 1<BR> next <BR>//return leftover array<BR><BR>Is there an easier way to do this? Can it be done or have I been playing to much Diablo?<BR><BR>Thanks<BR>sorCrer<BR>

  2. #2
    redim Guest

    Default RE: Array vs Array: Who knocks out whom!

    You can only remove an element from a VB array by shifting elements and ReDim()ing. Why not just create a 3rd array from the elements that match growing it as you proceed (with ReDim Preserve), and either return that array or overwrite the 1st array with this temp copy?

Posting Permissions

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