'往集合中加入一个“客户类型”对象
Public Sub Add(objType As CType)
mCol.Add objType, "A" & objType.ID
'在加入对象是,最好同时加入其“KEY”属性
'“KEY”属性不可以是数字型,因此在前面随便加
'一个字母,此处加了一个“A”
End Sub
Public Property Get Item(vntIndexKey As Variant) As CType
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
'本属性允许用 For...Each 语法枚举该集合。
Set NewEnum = mCol.[_NewEnum]
End Property
'清除集合中的全部元素
Public Sub Clear()
'注意!在清除时必须倒序清除,否则要出错!
Dim i As Long
For i = mCol.Count To 1 Step -1
mCol.Remove i
Next i
End Sub
Private Sub Class_Initialize()
Set mCol = New Collection
End Sub
Private Sub Class_Terminate()
Set mCol = Nothing
End Sub
没有看懂,不知道它想干吗?怎么一会引用,一会又全部删除
我是初学者,呵呵,见笑了!!请大侠们解答!!谢谢