
Originally Posted by
emc2
Hi all,
ArrayList is a generic structure.
Let's say I have my own structure (contained of Boolean+string+int). I want to set a dynamic array based on my own structure. How....?
Thanks!
This is a example about dynamic arrray :
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim scores() As Integer
ReDim scores(1)
scores(0) = 100
scores(1) = 200
For i = 0 To scores.Length - 1
MsgBox(scores(i))
Next
ReDim Preserve scores(2)
scores(2) = 300
For i = 0 To scores.Length - 1
MsgBox(scores(i))
Next
End Sub
End Class
If you want to keep the existing items in the Array , you can use the keyword Preserve .
ReDim Preserve scores(2) :
In this case the Array dynamically allocate one more String value and keep the existing values.