I am trying to create a database of events system in VB.net
whenever i try to access a variable within the array using
Events(x).EventName it creates a "
Dim Events(63) As EventRecord 'global as to be accessed by any subroutine
Dim Event1 As EventRecord
Public Class EventRecord
Public EventDate, EventTimeTaken As Integer 'creates structure for records of each event
Public EventMembers(63), EventNotes, EventName As String 'multiple data types are stored, meaning it must be a record
Public EventMoneyMade, EventCost, EventHourlyProfit, EventProfit As Decimal 'global as to be accessed by any subroutine
End Class
++ Event1 is then populated and added to the array in PopulateArray()
Sub PopulateArray()
Dim Empty As Boolean = False
Dim Temp
Dim j As Integer = 0
While Empty = False
Temp = Events(j)
If Temp = Nothing Then
Empty = True
Events(j) = Event1
Console.WriteLine("Array populated at location {0}", j)
Console.WriteLine(Events(j).EventName) #but this line creates an error
Else j = j + 1
End If
End While
End Sub
The error is "Object reference not set to an instance of an object"
Any help is greatly appreciated