I have a class called "Class1" and a class "Class2".

I want to create an instance of each and reference them to each other.

So what I do is:

VB Code:
  1. Public Class Class1
  2.     Dim myClass2 as new Class2
  3.  
  4.     Sub new ()
  5.         myClass2.set_myClass1(Me)
  6. End Sub
  7.  
  8. End Class
  9.  
  10. Public Class Class2
  11.     Dim myClass1 as new Class1
  12.  
  13.     Public Function set_myClass1 (ByRef myObject as Class1)
  14.         myClass1 = myObject
  15. End Function
  16. End Class

So the problem is that once I did myClass2.set_myClass1(Me) in Class1 the instance of Class1 is not referenced, but copied in Class2. So if I make any changes in the instance of Class1, the myClass1 in Class2 does not change!

Thank you very much for any advice as this is a major problem for my application.

Just for the story: in fact I need this to create a general "persistancyObject", that saves Objects to a relational db. If anybody is interested in this – or even could give some critic, your welcome and I'll post the code. But it is a bit complicate as you'll see…

Anyway, if someone could help me with the upper referencing problem, I would be more than glad!

Regards,
Fabian