Visual Studio Development Bookmark and Share   
 index > Visual Basic Express Edition > Defining an array of classes
 

Defining an array of classes

I'm trying to create an array of classes and unfortuneately am having some problems with nulls
this error specifically
A first chance exception of type 'System.NullReferenceException' occurred in myprogram.exe
pops up

this is what im trying to do in a module 

  Public Maps(30) As Map

where map is already a class containing several variables.

I am aware that if it were "Public Maps As Map" I would have to add "New" right before "Map"
but this is not possible if im trying to use an array.

Any suggestions?
berryblizzard  Friday, October 16, 2009 10:11 PM
Public Maps(30) as Map just creates an empty array.  If you try to access any elements before assigning them you will get the error you are seeing.

You need to assign instances of map to each element.
Dave299  Friday, October 16, 2009 10:13 PM

You can use google to search for other answers

Custom Search

More Threads

• Transforming code from VBA into Visual Studio
• displaying sql data in listbox
• how to connect to a sql 6.5 server
• Emergency!!
• add gadgets to my application
• Font error
• enter key
• DateTimePicker CloseUp event....
• Copy a Form or Make it a template
• Opinion wanted