Is there a smart way to return the key of a collection-object? I am interested in way like
Dim c as Collection
Set c = New Collection
c.Add "value1", "key1"
c.Add "value2", "key2"
Debug.Print c.Items(1) 'returns "value1"
Debug.Print c.Items("key1") 'returns "value1"
Debug.Print c.Keys(1) 'this does not work, but "key1" is wanted
The only way i know so far is
Dim keys as Collection
Set keys = New Collection
keys.Add "key1"
keys.Add "key2"
Dim c as Collection
Set c = New Collection
For i=1 to keys.Count
c.Add "value" & i,keys(i)
Next i
Debug.Print c(1) 'returns "value1"
Debug.Print keys(1) 'returns "key1"
But this way isn't very smart.