It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Array inside an array of structures [HELP]

Moderator: dafunkymunky

Array inside an array of structures [HELP]

Postby amoguai on Tue Feb 09, 2010 10:25 am

Hello fellows!

I've been searching the internet, books, eBooks and the forum for quite a while now and I haven't found the solution to this problem.

So, I need to create a structure with array elements and then I need to create an array of these structures.

Code: Select all
Structure infoSwimmer
        Dim name As String
        Dim grades(7) As Single <--- Error, one cannot initialize array size inside Structures for some reason
        Dim average As Single
        Dim rank As Single
    End Structure

    Dim swimmer(9) As infoSwimmer
    ReDim preserve swimmer.grades(7) <-- Error because ReDim cannot be used outside a Sub.

    Sub Main()
        ReDim Preserve swimmer(9).grades(7)
        swimmer(0).grades(0) = 5 <--- NullReferenceException error, so basicly the code above didn't redimensioned anything. And even if it did, the new ReDimensioned array would only be visible inside the Main(), right?
End Sub


So I ask, how can I create a global array of structures with array elements inside of it?

Much appreciated for any help,
Amoguai
amoguai
 
Posts: 1
Joined: Tue Feb 09, 2010 10:13 am

Who is online

Users browsing this forum: No registered users and 1 guest