Key Property |
Description
Sets a key in a Dictionary object.
PowerBASIC Syntax
Arguments
Remarks
If key is not found when changing a key, a new key is created and its associated item is left empty.
Example [PowerBASIC]
#INCLUDE "windows.inc" #INCLUDE "scrrun.inc"
DIM pDic AS IDictionary DIM vKey AS VARIANT DIM vItem AS VARIANT DIM newKey AS VARIANT DIM newItem AS VARIANT
' Create an instance of the Dictionaty object pDic = NEWCOM "Scripting.Dictionary" ' Add some key/item pairs to the dictionary vKey = "a" : vItem = "Athens" pDic.Add vKey, vItem vKey = "b" : vItem = "Belgrade" pDic.Add vKey, vItem vKey = "c" : vItem = "Cairo" pDic.Add vKey, vItem vKey = "c" ' Change key "b" to "m" and "Belgrade" to "México" vKey = "b" : vNewKey = "m" pDic.Key(vKey) = vNewKey vItem = "m" : vNewItem = "México" pDic.Item(vItem) = vNewItem ' Get the item for key "m" and display it vItem = EMPTY : vKey = "m" vItem = pDic.Item(vKey)
|