Array?

  • Thread starter Thread starter Able
  • Start date Start date
A

Able

Dear friends

Help me with an array task, I'm too old for this.

I have an two dimensional array myArr(x,y), imagine y is rows. I want to
preserve the existing array and add a new row to it. Then I want to move
every existing row down one row and make place for new items in myArr(x,0)

Regards Able
 
I would recommend you use another collection object that can grow
dynamically as needed, and allow you to insert items in the middle. Perhaps
an arraylist that contains either arrays, or possibly other arraylists.
 
Hi Able,

Did I not send you this before?

I extended it something with your insert question.

This should do your question.

\\\
Option Strict On
Public Module Main
' Sample of an arraylist that itself contains 10 classic arrays.
Public Sub Main()
Dim x As New ArrayList
Dim y() As Integer = {1, 2, 3, 4}
For i As Integer = 0 To 9
x.Add(y)
Next
MessageBox.Show(DirectCast(x(9), IList)(2).ToString)

'With option strict off you do not
'have to use the directcast but and than it is
'MessageBox.Show(a(2)(2).ToString) 'but I would not do that
'I show this to make it more classic looking for you.

'The Insert
Dim yN() As Integer = {5, 6, 7, 8}
x.Insert(1, yN)
MessageBox.Show(DirectCast(x(1), IList)(2).ToString)

End Sub
End Module
///

I hope this helps a little bit?

Cor
 
Back
Top