I know this isnt that great...but some people didnt know how to do so, so i figured id post it
Heres how we prevent doubles, and then find an index by an item name
VB Code:
Make 2 collections Dim Col1 As Collection Dim Col2 As Collection Private Sub Form_Load() On Error GoTo errhndler Dim iBool As Boolean Set Col1 = New Collection Set Col2 = New Collection Col1.Add "afda", "afda" If iBool = False Then Col2.Add col.Count, "afda" End If Col1.Add "adbdadba", "adbdadba" If iBool = False Then Col2.Add col.Count, "adbdadba" End If Col1.Add "ff3", "ff3" If iBool = False Then Col2.Add col.Count, "ff3" End If Col1.Add "r3ds", "r3ds" If iBool = False Then Col2.Add col.Count, "r3ds" End If '--- msgbox Col2.Item("adbdadba")'returns the index of adbdadba Exit Sub errhndler: If Err.Number = 457 Then iBool = True Resume Next End If End Sub
Hope its useful to someone..



Reply With Quote