Method: Keys for Dictionary
- Updated2024-09-12
- 1 minute(s) read
FileSystemObject and Dictionary > Methods > Method: Keys for Dictionary
Method: Keys for Dictionary
Returns an array with the keys of a Dictionary collection.
vKeys = Object.Keys
| Object | Dictionary Object with this method |
| vKeys | Variant Receives the array with the keys. |
The following example generates a Dictionary collection and adds some key/element pairs. Then the example displays the list of all keys:
Dim MyDic, MyKeys, MyKey, sOutput Set MyDic = CreateObject("Scripting.Dictionary") Call MyDic.Add ("a", "Austin") Call MyDic.Add ("b", "Berlin") Call MyDic.Add ("c", "Chicago") MyKeys = MyDic.Keys For Each MyKey in MyKeys sOutput = sOutput & MyKey & VBCrLf Next Call MsgBox(sOutput)