ID: 203
Viewed: 3387
Added: Apr 29, 2002
Version:
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo
Thank you for your vote. Please wait...
It appears you already voted for this snippet
It appears your vote value was empty
This class is a simple wrapper around VB's Collection object that exposes and "Exists" method.
Highlight all by clicking in box
<!---Declaration--->
Option Explicit
'local variable to hold collection
Private mCol As Collection
Public Function Exists(Key) As Boolean
Dim v As Variant
On Local Error GoTo NoItem
If IsObject(mCol(Key)) Then
Set v = mCol(Key)
Set v = Nothing
Else
v = mCol(Key)
End If
Exists = True
Exit Function
NoItem:
Exists = False
Exit Function
End Function
Public Sub Clear()
Set mCol = New Collection
End Sub
Public Sub Add(Item, Optional Key, Optional Before, Optional After)
If IsMissing(Key) Then
mCol.Add Item
Else
If IsMissing(Before) Then
mCol.Add Item, Key
Else
If IsMissing(After) Then
mCol.Add Item, Key, Before
Else
mCol.Add Item, Key, Before, After
End If
End If
End If
End Sub
Public Property Get Item(vntIndexKey As Variant) As Variant
If IsObject(mCol(vntIndexKey)) Then
Set Item = mCol(vntIndexKey)
Else
Item = mCol(vntIndexKey)
End If
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()
'creates the collection when this class is created
Set mCol = New Collection
End Sub
Private Sub Class_Terminate()
'destroys collection when this class is terminated
Set mCol = Nothing
End Sub
Highlight All
<!---Code--->
none;
No Comments to show
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Adding your comment. Please wait...
Thanks for adding your comment!. After further review it will be added.
There was a problem adding your comment. Please try again.
Please complete all the fields in the form before sending.