Hello, I'm posting in hopes of someone being able to help me figure out what I'm doing wrong in the following code
and within the main app:
And the output I'm getting is:
"Test Name"
"Error=Object reference not set to an instance of an object"
I understand the error is saying I've got a null pointer reference happening, but I don't understand why. Anyone smarter than me able to help?
Thanks a lot!!
VB.NET:
Public Class HouseAddress
Public Property HouseNumber As Integer
Public Property StreetName As String
Private Sub Init()
HouseNumber = 0
StreetName = "TEST ST"
End Sub
End Class
VB.NET:
Public Class Person
Public Property Name As String
Public Property Location As HouseAddress
Private Sub Init()
Name = "Test Name"
Location = new HouseAddress()
End Sub
End Class
VB.NET:
Class Window1
Dim Tora as Person
Private Sub Init()
Tora = new Person()
Debug.WriteLine(Tora.Name)
Try
Debug.WriteLine(Tora.Location.StreetName)
Catch ex As Exception
Debug.WriteLine("Error=" + ex.Message)
End Try
End Sub
End Class
And the output I'm getting is:
"Test Name"
"Error=Object reference not set to an instance of an object"
I understand the error is saying I've got a null pointer reference happening, but I don't understand why. Anyone smarter than me able to help?
Thanks a lot!!