J
Jeremy Benenati
Hi all,
I am trying to make a class that when you create a 2nd instance the second instance will be a reference to the first.
Public Class ClassA
Private Shared tableList As Hashtable
Public myInt as integer = 0
Public Sub New()
MyBase.New()
InitializeValues()
End Sub
Private Function openTable() As Boolean
If (tableList Is Nothing) Then
tableList = New Hashtable()
End If
If (tableList.ContainsKey(TABLE)) Then
SetReference(Me, tableList(TABLE))
OpenCount += 1
Else
OpenCount += 1
tableList.Add(TABLE, Me)
End If
End Function
Public Shared Sub SetReference(ByRef obj As Object, ByRef newObj As Object)
obj = newObj
End Sub
End Class
Public Sub Test()
Dim myClass1 as new ClassA
Dim myClass2 as new ClassA
'set myInt = 200 for both
myClass1.myInt = 200
End Sub
Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET Cookies FAQ
http://www.eggheadcafe.com/tutorial...388-89e5-fce33d725aa7/aspnet-cookies-faq.aspx
I am trying to make a class that when you create a 2nd instance the second instance will be a reference to the first.
Public Class ClassA
Private Shared tableList As Hashtable
Public myInt as integer = 0
Public Sub New()
MyBase.New()
InitializeValues()
End Sub
Private Function openTable() As Boolean
If (tableList Is Nothing) Then
tableList = New Hashtable()
End If
If (tableList.ContainsKey(TABLE)) Then
SetReference(Me, tableList(TABLE))
OpenCount += 1
Else
OpenCount += 1
tableList.Add(TABLE, Me)
End If
End Function
Public Shared Sub SetReference(ByRef obj As Object, ByRef newObj As Object)
obj = newObj
End Sub
End Class
Public Sub Test()
Dim myClass1 as new ClassA
Dim myClass2 as new ClassA
'set myInt = 200 for both
myClass1.myInt = 200
End Sub
Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET Cookies FAQ
http://www.eggheadcafe.com/tutorial...388-89e5-fce33d725aa7/aspnet-cookies-faq.aspx