You can use a method something like this to delete a row in a 2D
numeric array:
Sub DeleteRow(mArray(,) as double, Row as integer)
dim i, j as integer
dim LastRow, LastColumn as integer
LastRow = UBound(mArray,1) //cache some limits
LastColumn = UBound(mArray,2)
For i = Row to LastRow
For j = 0 to LastColumn
If i + 1 <= LastRow then
mArray(i, j) = mArray(i +1, j)
End if
Next
Next
Redim mArray(LastRow - 1, LastColumn)
End Sub
Note the "," in the parameter mArray(,).
For a test call, from a button, for example:
dim MultiArray(10,10) as double
dim i, j,UboundRow,UBoundCol as integer
'Populate an array with whatever
For i = 0 to 2
For j = 0 to 2
MultiArray(i, j) = i + j + 1
Next
Next
'set UBound to reflect actual population before call
Redim MultiArray(i -1, j -1)
'Call method to delete row 2 of MultiArray
DeleteRow(MultiArray, 2)
HTH,
Jack
On Jan 9, 2005, at 11:59 AM, Joseph J. Strout wrote:
I can't seem to find a simple way to delete a row of a
multi-dimension array, from the middle of the array, given that the
array.remove method only works for single dimension arrays?
That's right. There's no simple way to remove a column, either (nor
a higher-dimensional slab of a multi-dimensional arrays).
Is the only way some strange re-assignment and redim operation?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|