Keys
Returns a String array containing all the keys associated with items in a Collection object.
Syntax: object.Keys()
- object
- required An object expression that evaluates to a Collection object.
Note
Keys is a twinBASIC extension; the classic VBA Collection object has no Keys method.
Only items that were added with a Key argument appear in the returned array. If no items have keys, the array is empty.
Example
Dim col As New Collection
col.Add "Athens", Key:="a"
col.Add "Belgrade", Key:="b"
col.Add "Cairo", Key:="c"
Dim k() As String
k = col.Keys
Dim i As Long
For i = LBound(k) To UBound(k)
Debug.Print k(i), col(k(i))
Next i