K
Kees de Winter
HI,
How can I access the fields and methods of a subclass in a variable that was
declared as a parent-class and instantiated as a subclass.
Public Class Communication
Public Response As Message
some more stuff
End Class
Public Class Message
some fields, methods etc.
End Class
Public Class Letter
Inherits Message
Public Stamp As String
End Class
Public Class Email
Inherits Message
Public Emailaddress As String
End Class
Now in the main procedure, say pageload, I'd like to easily use code like
this:
Dim Communication1 As New Communication
Communication1.Response.EmailAddress = "bla"
But of course it's not possible, I need to use:
CType(Communication1.Response, Email).EmailAddress = "bla"
Is there a way to accomplish this? I have also tried by providing a
Enum-type variable in the constructor of the Communication class and then to
instantiate "Response" with the chosen subclass but to no avail.
Thank you for your time.
How can I access the fields and methods of a subclass in a variable that was
declared as a parent-class and instantiated as a subclass.
Public Class Communication
Public Response As Message
some more stuff
End Class
Public Class Message
some fields, methods etc.
End Class
Public Class Letter
Inherits Message
Public Stamp As String
End Class
Public Class Email
Inherits Message
Public Emailaddress As String
End Class
Now in the main procedure, say pageload, I'd like to easily use code like
this:
Dim Communication1 As New Communication
Communication1.Response.EmailAddress = "bla"
But of course it's not possible, I need to use:
CType(Communication1.Response, Email).EmailAddress = "bla"
Is there a way to accomplish this? I have also tried by providing a
Enum-type variable in the constructor of the Communication class and then to
instantiate "Response" with the chosen subclass but to no avail.
Thank you for your time.