The key needs to be alpha-numeric. so if your program is keeping track of an "Index", then set the key to something like "E" & Index (see below)
Dim colMyCollection As Collection
Dim intEmpID As Integer
Dim objMyObject As New OrgChart.Employee 'this is my class
Dim rsEmployees As ADODB.Recordset
Dim strNames As String
'This populates my collection with all employees
Set rsEmployees = GetEmployees()
With rsEmployees
Do Until .EOF
objMyObject.EmpID = .EmpID
objMyObject.ReportToID = .ReportToID 'this is the boss's EmpID
objMyObject.LastName = .LastName
'etc.
colMyCollection.Add objMyObject, "E" & CStr(.EmpID) 'I add a letter so the program knows it's a key, not an index#
.MoveNext
Loop
End With
'This finds the corporate hierarchy of an employee
'giving a string that list all of the employee's superiors
'The president of the company doesn't have a boss, so his .ReportToId = 0
intEmpID = CInt(Text1.Text)
Set objMyObject = colMyCollection("E" & CStr(intEmpID))
strNames = objMyObject.LastName
intEmpID = objMyObject.ReportToID
Do Until intEmpID = 0
Set objMyObject = colMyCollection("E" & CStr(intEmpID))
strNames = objMyObject.LastName & ", " & strNames
intEmpID = objMyObject.ReportToID
Loop
'the output might look like this(the president is Jones, the employee Smith:
'Jones, Davis, Doe, Smith