Hi All,
I have a problem looping thru a collection. Can anyone please help me out with this......
I have this following code.....

Public mcolContacts As New Collection

Public Sub Add(CustomerID As Long, SiteName As String, ContactName As String)
Dim udtContact As ContactType
Dim key As String

With udtContact
.CustomerID = CustomerID
.SiteName = SiteName
.ContactName = ContactName
.Selected = False
End With
key = "CID:" & CustomerID
End Sub

Now I have 2 conditions
1)I want to remove the item if it already exists and add the same item with the updated value OR
2)Add a new item if it is not present in the collection.

The code for this is code is as follows
if key exists then
mcolContacts.Remove key mcolContacts.Add udtContact, key
Else
mcolContacts.Add udtContact, CStr(key) End If