Could anyone suggest an alternative to using a collection to store a string with corresponding ID? I could use an array but it would be a UDT and I will need to search through all the collections to compare its ID before I can do a deletion so I am not sure if that is the correct path. I have tried the Dictionary object of the Scripting Runtime but oddly it not working as I would have expected, it is giving me incorrect results.

Any suggestions are welcome.


Code:
Private colStacks   As Collection
Private stackID     As Long

Public Function PushStack(ByVal strProcedure As String) As Long
    'when in error handling routine then don't register traces
    If SkipTrace = True Then Exit Function

    If colStacks Is Nothing Then Set colStacks = New Collection
    stackID = stackID + 1
    colStacks.Add strProcedure, "K" & stackID
    PushStack = stackID
End Function

Public Sub PopStack(ByVal ID As Long)
    If Not colStacks Is Nothing Then
        If colStacks.Count > 0 And ID > 0 Then
            colStacks.Remove "K" & ID
            If ID = stackID Then
                stackID = stackID - 1
            End If
        End If
    End If
End Sub