Login   /   Register

Delete One Element from a Dictionary

Rate this article
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...
April 1st, 2008 by daniva

Demonstration script that deletes a specific key-item pair from a Script Runtime Dictionary. Script must be run on the local computer.

Set oDictionary = CreateObject("Scripting.Dictionary")
 
oDictionary.Add "Printer 1", "Printing"   
oDictionary.Add "Printer 2", "Offline"
oDictionary.Add "Printer 3", "Printing"
 
keysCol = oDictionary.Keys
 
Print  "First run: " 
For Each keyStr in keysCol 
    Print keyStr
Next
 
oDictionary.Remove("Printer 2")
keysCol= oDictionary.Keys
 
Print "Second run: " 
For Each keyStrin keysCol
    Print keyStr
Next

Posted in Dictionary Objects

Leave a Reply

You must be logged in to post a comment.

This article was viewed 414 times