Im making a sim of a robocup for a project and it would really help make the code easier to read if I could have an array of players but I cant dim and array as new and my players are all a class I made called gameobject.
How do I make an array of players as my class gameobject?

Dim i As Integer = -1
        i += 1
        ReDim Preserve MyPlayers(i)
        MyPlayers(i) = TextBox1.Text

Edited 7 Years Ago by Nick Evan: Added code-tags

thats not the problem I wanted to know if there was a way to dim an array as a class like:
Dim players(9) as new gameobject
but you cant dim one as new and if i just do:
Dim players(9) as new gameobject
it says "object reference not set to an instance of an object"

you need to initialize each player as new gameobject

Dim players(9) As gameobject
        For i As Integer = 0 To players.Length - 1
            players(i) = New gameobject
            players(i).testProperty = CStr(i)

        For i As Integer = 0 To players.Length - 1
This question has already been answered. Start a new discussion instead.