Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 297
Viewed: 2966
Added: Sep 10, 2002
Version: 5+
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

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
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
v = mCol(Key)
End If

Exists = True
Exit Function
Exists = False
Exit Function
End Function

Highlight All
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
If IsMissing(Before) Then
mCol.Add Item, Key
If IsMissing(After) Then
mCol.Add Item, Key, Before
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)
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;

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

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.

© 2002 - 2018 All Rights Reserved. Conditions