Item Property

 

Description

 

Sets or returns an item for a specified key in a Dictionary object. For collections, returns an item based on the specified key. Read/write.

 

PowerBASIC Syntax

 

PROPERTY GET Item ( _

BYREF IN vKey AS VARIANT _

) AS VARIANT

 

PROPERTY SET Item ( _

BYREF vKey AS VARIANT _

BYREF vNewItem AS VARIANT _

)

 

PROPERTY SET putref_Item ( _

BYREF vKey AS VARIANT _

BYREF vNewItem AS VARIANT _

)

 

Arguments

 

vKey

Key associated with the item being retrieved or added.

vNewItem

The new value associated with the specified key.

 

Remarks

 

If key is not found when changing an item, a new key is created with the specified vNewItem. If key is not found when attempting to return an existing item, a new key is created and its corresponding 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"

vKey = "a" : vItem = "Athens"

' Add some key/item pairs to the dictionary

pDic.Add vKey, vItem

vKey = "b" : vItem = "Belgrade"

pDic.Add vKey, vItem

vKey = "c" : vItem = "Cairo"

pDic.Add vKey, vItem

' 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)

 

Valid XHTML 1.0 Transitional