Public Class Form1
Structure Crap
Dim CrapA As Integer
Dim CrapB As Single
Dim CrapC() As Long
Private Sub Initialize()
ReDim CrapC(0 To 100)
End Sub
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Stuff(0 To 2) As Crap
Stuff(0).CrapA = 16
Stuff(1).CrapA = 32
Stuff(2).CrapA = 64
'This is the line where the NullReferenceException is thrown
Stuff(0).CrapC.Initialize()
For x = 0 To 100
Stuff(0).CrapC(x) = x ^ 2
Next x
MsgBox(Stuff(0).CrapA)
MsgBox(Stuff(1).CrapA)
MsgBox(Stuff(2).CrapA)
For x = 0 To 100
MsgBox(Stuff(0).CrapC(x))
Next x
End Sub
End Class
So this is a pretty simple program with a baffling error. All I want is an array in my user defined type. I'm moving from VB6 to .net and everything I've read, including What is a NullReferenceException, and how do I fix it? which is a hearty read, doesn't help. Seems I'm stuck in 1999, lol. I understand that the array CrapC is null, it's making it not null that's the problem.