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.
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.