I'm writing code and there is a null reference exception. I can see where it is, but I can't work out how to fix it. I'm honestly not sure why, I've been reading and re-reading my code, trying different things. I think I'm being dense or possibly have a mental block on it somehow.
The two bits of code are :
For looper = 0 To 3
Sandpit.Controls.Add(Me.QueueMembers(looper).VisRep)
Me.QueueMembers(looper).VisRep.ForeColor = Me.QueueMembers(looper).GetBackgroundColour
Select Case (Me.Direction)
Case "R"
TempPoint.X += 32
TempPoint.Y = 260
Case "U"
TempPoint.Y += 32
Case "L"
TempPoint.X -= 32
End Select
Which works for creating a queue and everything. When I try to remove anything from the queue, though, using the following code:
Public Sub RemoveDiner()
Dim TempDiner As Diner
For looper = 0 To Me.EndPointer - 1
TempDiner = QueueMembers(looper)
QueueMembers(looper) = QueueMembers(looper + 1)
Next
DrawQueue()
End Sub
It's the looper causing the problem, I think because once the item is deleted, there aren't three items in the QueueMembers array. If someone could just give me advice on how to fix this because I'm being completely dense about it, please, I would be very grateful. Thanks!