JackOfHearts
New member
- Joined
- Mar 29, 2005
- Messages
- 3
- Programming Experience
- 10+
Many apologies if this is in the wrong forum. I am a new user and cannot see a more relevant one.
Could someone explain why the following code will not work for me? I am an experienced programmer but somewhat inexperienced in OOP and VB .NET in particular.
What I am trying to do is to get instances of the inner nested classes to talk directly to each other without reference to the instance of the outer class.
The code fails in the IDE because the reference to Object3 in class Class2 is not declared. It is not declared in Class2 but it is in the outer class (Class1) which to my understanding should be accessible from the inner class.
I have tried various ways to overcome this problem but to no avail. I think that I am suffering from trying to take too many new ideas on board at one time here. Have any of you more experienced people any suggestions on this?
Could someone explain why the following code will not work for me? I am an experienced programmer but somewhat inexperienced in OOP and VB .NET in particular.
What I am trying to do is to get instances of the inner nested classes to talk directly to each other without reference to the instance of the outer class.
The code fails in the IDE because the reference to Object3 in class Class2 is not declared. It is not declared in Class2 but it is in the outer class (Class1) which to my understanding should be accessible from the inner class.
VB.NET:
Public Class Class1
Private Class Class2
Function Method2()
MsgBox("I am Method2 as defined in Class2")
Object3.Method3()
End Function
End Class
Private Class Class3
Function Method3()
MsgBox("I am Method3 as defined in Class3")
End Function
End Class
Sub New()
Dim Object2 As New Class2
Dim Object3 As New Class3
Object2.Method2()
End Sub
End Class
Last edited by a moderator: