Click to See Complete Forum and Search --> : [RESOLVED] List of Lists?


mwbell
November 15th, 2009, 02:39 PM
I'm trying to make a list of flight plans loaded into my program, with each flight plan having a list of waypoints along the route, along with a few other properties associated with the flight plan. Each waypoint has its own associated properties, i.e. waypoint ID, waypoint type, location, etc.

Here's the declarations:



Public Class WPinfo
Public WPType As String
Public WPID As String
Public WPName As String
Public WPAltitude As Integer
End Class
Public Class FlightPlan
Public FileName As String
Public Waypoints As List(Of WPinfo)
End Class

Public FlightPlans As List(Of FlightPlan)



How do I implement the List methods to access the list elements, and add, remove, etc? The way I'm doing it now just gets me an 'Object reference not set to an instance of an object' error during runtime.

Thanks!

mwbell
November 15th, 2009, 07:03 PM
Solved this one myself...

makdu
November 16th, 2009, 03:36 AM
Wat was the problem and how you resolved it?

mwbell
November 18th, 2009, 08:11 PM
I created a single new instance of my WPInfo called 'thisWP'. Every time I loaded in a waypoint, I put my converted info into thisWP, and then added thisWP to my waypoint list using the Add() method once I was done processing the info for the current waypoint. I am able to reference my flight plans and their waypoints using index references in the lists once I've actually added items to them. I kept trying to reference my lists and set values in them as if they were arrays before I had 'added' anything to them, which doesn't work.