Hi,
I would like to describe my application here, pls kindly read through
it.
In my app, I have 2 classes QRecord and QRecords, and class QRecords is
a collection of class QRecord. Codes are listed below.
1.Code of QRecord
Private mvarParentPointer As Variant
Public Function GetParent() As QRecords
Dim oTemp As Object
'********************************************
CopyMemory oTemp, mvarParentPointer, 4
'*********************************************
Set GetParent = oTemp
CopyMemory oTemp, 0&, 4
End Function
Friend Property Let ParentPointer(ByVal vData As Variant)
mvarParentPointer = vData
End Property
Friend Property Set ParentPointer(ByVal vData As Variant)
Set mvarParentPointer = vData
End Property
2.Code of QRecords
Private mCol As Collection
Public Function Add(Optional sKey As String) As QRecord
Dim objNewMember As QRecord
Set objNewMember = New QRecord
'***********************************************************
objNewMember.ParentPointer= ObjPtr(Me)
'***********************************************************
If Len(sKey) = 0 Then
mCol.Add objNewMember
Else
mCol.Add objNewMember, sKey
End If
Set Add = objNewMember
Set objNewMember = Nothing
End Function
Public Property Get Item(vntIndexKey As Variant) As QRecord
Set Item = mCol(vntIndexKey)
End Property
Public Property Get Count() As Long
Count = mCol.Count
End Property
Public Sub Remove(vntIndexKey As Variant)
mCol.Remove vntIndexKey
End Sub
Public Property Get NewEnum() As IUnknown
Set NewEnum = mCol.[_NewEnum]
End Property
Private Sub Class_Initialize()
Set mCol = New Collection
End Sub
Private Sub Class_Terminate()
Set mCol = Nothing
End Sub
QRecord have a pointer to it parent without counting reference to
QRecords, so that instance of QRecords can be destroyed when it is set to
nothing, no need to enumerate all QRecord items and set them to nothing one
by one in case QRecord has an attribute of QRecords referencing it parent
dirrectly.
Hope I am understood and able to get your help. Thanks in advanced.