Array.Copy and Multi-dimensional arrays...

R

rmorvay

I have a requirement to search a multi-dimensional array for an item, then
delete the item and "reset" the array so that their are no gaps in the
resulting array. I have been trying to figure out how to use the Array.Copy
method to accomplish this but it seems to only work for single dimension
arrays. Here is a code sample:

'dim arrTest(600,3) as string 'Actual array dimension needed
dim arrTest(600) as string 'Used only in this test
dim intIndex as Integer
dim randomNum as New Random()

'Get random index into array for delete test
intIndex = random.Next(0, UBound(arrTest))

'Shifts elements from arrTest(intIndex + 1) to arrTest(intIndex)
Array.Copy(arrTest, intIndex + 1, arrTest, intIndex, UBound(arrTest) - 1)

'Clears the last element
arrTest.Clear(arrTest, arrTest.GetUpperBound(0), 1)

Any idea on how to modify this code or let me know a better approach to
doing this for a multidimensional array?

Thanks in advance.
 
R

rmorvay

I am not sure how I could use the ArrayList. My understanding is that the
ArrayList is a single dimension approach. Would I have to deconstruct the 2
dimensional array to accomplish this?
 
R

rmorvay

Thanks. I think I can use an ArrayList with a structure to accomplish my
requirements without a need for a major code overhaul.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top