View Single Post
  #1 (permalink)  
Old June 18th, 2004, 10:28 AM
hashtlishnii hashtlishnii is offline
Authorized User
 
Join Date: Jun 2003
Location: Farmington, NM, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Instantiate Integer array in a stucture

Hello all,
I'm working with VB.NET 2002, 1.0 Framework. Here's my problem: I'm trying to create a STRUCTURE with an array element. The STRUCTURE looks like this:

Private Structure StructOfLabs
    Dim LabGroup As String
    Dim Hours() As Integer
End Structure

My big problem comes when I try to put stuff into the array. I can get to the LabGroup ok, but the compiler doesn't like me trying to access Hours() until I instantiate it. It tells me:
"An unhandeled exception of type 'System.NullReferenceException' occured in UpdateCalendar.exe

Additional information: Object reference not set to an instance of an object."

myLabs(0).LabGroup = ""
myLabs(0).Hours(0) = 0

I've searched & searched and I get tantalizing hints of how to go about it, but nothing materalizes. I would sure appreciate a bit of help. Thanks, all. -RK
__________________
She stood on the bridge at midnight,
Her lips were all aquiver.
She gave a cough,
Her leg fell off,
and floated down the river.
Reply With Quote