Is there an easier or faster way to remove a row or a column in a two dimension array?
Let’s imagine that I have a 2 dim array Matrix(ntr, ntc) and I want to delete row “nr”
[code]'Remove row nr
'ntr=numberof rows, ntc=number of columns
For r As Integer = nr To ntr - 1
For c As Integer = 0 To ntc
If UBound(Matrix, 1) < r + 1 Then Continue
If UBound(Matrix, 2) < c Then Continue
Matriu(r, c) = Matriu (r + 1, c)
Redim Matrix(ntr - 1, ntc)[/code]
Thanks for any hint.
From the docs…
The remove method works with one-dimensional arrays only
Thanks Emile and Roger.
I tried to involve “Remove” but I couldn’t since it doesn’t work with 2 dim arrays.
Anyway, I think the best solution consists in creating a class Matrix (arrays with two dimensions) and methods in it to remove rows or columns.
Will work once you removed a Column
Or a Method that copy one column only / only some rows ?
Something tells me you need to copy the array or cast it to a memorytblock.