VBNotebook Home | Functions | Does Collection Key Exist
This function checks to see if the specified key is in the specified collection. It returns a true if it is, false if not.
__________________________________________________________________________________________
Public Function InCollection(colTest As Collection, ByVal sKey As String) As Boolean
On Error GoTo NOT_FOUND
If VarType(colTest.Item(sKey)) = vbObject Then
'
' This test will indicate if the item actually exists in the
' collection by causing an error if the item does not exists
'
End If
InCollection = True
Exit Function
NOT_FOUND:
InCollection = False
End Function
__________________________________________________________________________________________
Copyright 2000-2005, J. Frank Carr