Method: Remove for Dictionary
- Updated2024-09-12
- 1 minute(s) read
FileSystemObject and Dictionary > Methods > Method: Remove for Dictionary
Method: Remove for Dictionary
Deletes a key/element pair from a Dictionary collection.
Object.Remove(Key)
| Object | Dictionary Object with this method |
| Key | Variant Specifies the key. |
The following example generates a Dictionary collection and adds some key/element pairs. Then the example checks whether the key "a" exists and deletes the key accordingly:
Dim MyDic Set MyDic = CreateObject("Scripting.Dictionary") Call MyDic.Add ("a", "Austin") Call MyDic.Add ("b", "Berlin") Call MyDic.Add ("c", "Chicago") ' ... Further instructions If MyDic.Exists("a") Then Call MyDic.Remove ("a") End If