views:

269

answers:

4

Can I get an example of how to make something like a Vector or an ArrayList in Visual Basic .NET?

+1  A: 

Try the following

Dim list As New ArrayList()
list.Add("hello")
list.Add("world")
For Each cur As String in list
  Console.WriteLine(cur)
Next
JaredPar
A: 

Module Module1

    Sub Main()
        Dim al As New ArrayList()
        al.Add("1")
        al.Add("2")
        al.Add("3")
    End Sub

End Module
Chris McCall
+7  A: 
Dim list As New ArrayList

or (equivalently):

Dim list As ArrayList = New ArrayList

If you want a generic List (very similiar to ArrayList):

Dim list As New List(Of String)

Also see the ArrayList and List documentation.

cdmckay
+1 for mentioning List(Of T) - this is a better alternative than ArrayList.
Reed Copsey
ArrayList is going to be depricated and, from what I understand, isn't even available in some platforms such as Silverlight.
Jonathan Allen
A: 

If you happen to be using VB10 you should be able to use the following syntax.

Dim list As New List(Of Integer) From { 1, 2, 3, 4, 5 }
Brian Gideon