Property: Key for Dictionary
- Updated2024-09-12
- 1 minute(s) read
FileSystemObject and Dictionary > Properties > Property: Key for Dictionary
Property: Key for Dictionary
Specifies the key for a Dictionary collection.
Object.Key(Key)
| Object | Dictionary Object with this property |
| Key | Variant Specifies the key. |
| Object.Key | Variant with read and write access |
The following example generates a Dictionary collection and adds some key/element pairs. Then the example renames the key to "b" and displays the element that belongs to the new key "MyB":
Dim MyDic, MyItem Set MyDic = CreateObject("Scripting.Dictionary") Call MyDic.Add ("a", "Austin") Call MyDic.Add ("b", "Berlin") Call MyDic.Add ("c", "Chicago") MyDic.Key("b") = "MyB" MyItem = MyDic.Item("MyB") Call MsgBox("Item MyB: " & MyItem)