While I've been coding in VB in the past, I am pretty new to VB.Net
and have a lot of catching up to do. I'm working on a project that
requires a two dimensional array and instead of using traditional
arrays, I thought collections may be the way to go instead.

I'll best use an example to illustrate what the heck I'm talking
about. What I want is an Array of Teams, where each team contains an
array of first and last names. So I went on to define some structures
like the following:

    Public Structure Names
        Dim FName As String
        Dim LName  As String
    End Structure

    Public Structure Teams
        Dim Team As String
        Dim Members As Collection
    End Structure

I am calling a function which reads data from a file and all looks
good. Once finished reading, I have a collection named "colTeams",
which contains several "Teams" and each contains the Name of the team
and a list of team members. All works as it should. The real problem
starts when I return from the function. I still have the names of the
Teams in the collection "colTeams" and the Count-property is set
correctly to the number of teams but the collection "Members" in each
element is empty and the Count-property is zero.

To explain what I mean:

After the function which reads the data is finished, I can query all
values inside the collection in the debug window. So will the line "?
colTeams(2).Members.Count" print the value "3" as it should since the
team 2 has 3 members. After I return from the function, the same query
will return "0". So I still have a list of teams and the names of the
teams but the collection with the names of every team member is gone.

Any idea what's going on? Am I missing something?

Cheers
Aussiekraut

Reply via email to