Y
Yuk Tang
Leading on from a recent topic, "How does child class access parent's
variables", I would like to ask, what's the most elegant way of
changing a parent/grandparent/great-grandparent's property?
The class Nest has a subclass SubNest. Within SubNest I want to work
with Title. I think if I can pass Title ByRef to the children and
grandchildren, it would work, but VB doesn't do so by default, and
indeed warns me against it: "Reference to a non-shared member
requires an object reference."
Public Class Nest
Private mstrTitle As String
Private mstrSubNests As SubNest
Public Property Title() As String
Public Property SubNests() As SubNest
Public Class SubNest
Private mstrNestBoolean As Boolean
Public Property NestBoolean() As Boolean
Public Sub Feck()
If NestBoolean = True Then
Title = "Hello"
End If
End Sub
End Class
End Class
variables", I would like to ask, what's the most elegant way of
changing a parent/grandparent/great-grandparent's property?
The class Nest has a subclass SubNest. Within SubNest I want to work
with Title. I think if I can pass Title ByRef to the children and
grandchildren, it would work, but VB doesn't do so by default, and
indeed warns me against it: "Reference to a non-shared member
requires an object reference."
Public Class Nest
Private mstrTitle As String
Private mstrSubNests As SubNest
Public Property Title() As String
Public Property SubNests() As SubNest
Public Class SubNest
Private mstrNestBoolean As Boolean
Public Property NestBoolean() As Boolean
Public Sub Feck()
If NestBoolean = True Then
Title = "Hello"
End If
End Sub
End Class
End Class