• Welcome to Jose's Read Only Forum 2023.
 

IDictionary.Item Property

Started by José Roca, July 13, 2008, 10:21:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example illustrates the use of the Item property.

JScript


function GetItem(keyword)
{
   var a, d;
   d = new ActiveXObject("Scripting.Dictionary");
   d.Add("a", "Athens");
   d.Add("b", "Belgrade");
   d.Add("c", "Cairo");
   a = d.Item(keyword);
   return(a);
}


VBScript


Function GetItem
   Dim d   ' Create some variables.
   Set d = CreateObject("Scripting.Dictionary")
   d.Add "a", "Athens"   ' Add some keys and items.
   d.Add "b", "Belgrade"
   d.Add "c", "Cairo"
   GetItem = d.Item("c")   ' Get the item.
End Function


PowerBASIC


FUNCTION GetItem () AS STRING

   LOCAL d AS IDictionary
   LOCAL vKey AS VARIANT
   LOCAL vItem AS VARIANT

   d = NEWCOM "Scripting.Dictionary"
   vKey = "a" : vItem = "Athens"
   d.Add vKey, vItem
   vKey = "b" : vItem = "Belgrade"
   d.Add vKey, vItem
   vKey = "c" : vItem = "Cairo"
   d.Add vKey, vItem
   vKey = "c"
   vItem = d.Item(vKey)
   FUNCTION = VARIANT$(vItem)

END FUNCTION