H
Hugh
Hi,
Is there easy way to delete elements from a 2D array?
Thanks for your tip.
Hugh
Is there easy way to delete elements from a 2D array?
Thanks for your tip.
Hugh
* "Hugh said:Is there easy way to delete elements from a 2D array?
Hugh said:Is there easy way to delete elements from a 2D array?
* "Cor said:If the 2d array is a datatable or an arraylist, than it is easy possible
using remove, removeat with arraylist (or other implementations of Ilist
arrays)
\\\1, 2, 4, 5
1, 1, 1, 5
3, 4, 9, 1
1, 1, 1, 1
How to delete the "9"?
* "Cor said:The example is something larger
Hugh said:Thank you all for your reply. I am sorry that original
post was misleading. It should be "delete a row" not a
element. Let's say, I have a 2D array:
0,1
2,3
4,5
6,7
8,9
10,11
12,13
14,15
and I want to delete row 3 from the array. What is the
easiest way to do it? Thanks again.
* "Cor said:Did you look at my arraylist sample?
Hi Armin,-----Original Message-----
<quote>
Another option is to copy the items within the array to the new position
(overwriting the item to be removed), then use Redim Preserve to change the
size. Redim Preserve also creates a new array, but it might be the simplest
solution. Nevertheless, Redim Preserve can only change the size of the
highest rank.
</quote>
If you have specific problems to implement this solution, please let us
know.
--
Armin
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
.
Thank you very much, Cor, for your sample code. I never-----Original Message-----
Hi Hugh,
I was busy with the homework from Herfried (is only joking) I changed a
little to make it more viewable for you but not exact as your example.
I hope this helps,
Cor
\\\
Public Module Main
Sub main()
Dim Hkw(,) As Integer = {{1, 2, 3, 4}, _
{1, 1, 1, 5}, {3, 4, 9, 1}, {1, 1, 1, 1}}
Dim R As New ArrayList
For i As Integer = 0 To 3
Dim C As New System.Text.StringBuilder
For y As Integer = 0 To 3
C.Append(Hkw(i, y))
Next
R.Add(c)
Next
MessageBox.Show(R(2).ToString)
R.RemoveAt(2)
MessageBox.Show(R(2).ToString)
End Sub
///
I think that I understand your idea. You meant to
redefine the array by excluding specified row(s) by using
Redim Preserve statement. Let me know if that is not what
you said. Thanks.