Tuesday 30 July 2013

Dictionary Object

Dictionary Object is a object that stores data key, item pairs.

A Dictionary object is the equivalent of a PERL associative array. Items can be any form of data, and are stored in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually an integer or a string, but can be anything except an array.

Following methods can be used with Dictionary Objects:

1-Add- Adds a key and item pair to a Dictionary object.
2-Exists- Returns true if a specified key exists in the Dictionary object, false if does not.
3-Items- Returns an array containing all the items in a Dictionary object.
4-Keys- Returns an array containing all existing keys in a Dictionary object.
5-Remove- Removes a key, item pair from a Dictionary object.
6-RemoveAll- RemoveAll method removes all key, item pairs from a Dictionary object.

The following code illustrates how to create a Dictionary object:


Dim d   'Create a variable.
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens"   ' Add some keys and items.
d.Add "b", "Belgrade"
d.Add "c", "Cairo"

If d.Exists("c") Then
    msg = "Specified key exists."
Else
   msg = "Specified key doesn't exist."
End If

a = d.Items   ' Get the items.
For i = 0 To d.Count -1 ' Iterate the array.
   s = s & a(i) & "<BR>" ' Create return string.
Next

b = d.Keys   ' Get the keys.
For j = 0 To d.Count -1 ' Iterate the array.
    t = t & b(j) & "<BR>" ' Return results.
Next

d.Remove("b")   ' Remove second pair.
c = d.RemoveAll   ' Clear the dictionary.


8 comments:

  1. Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays. Well written article Thank You for Sharing with Us pmp training Chennai | pmp training centers in Chennai | pmp training institutes in Chennai | pmp training and certification in Chennai

    ReplyDelete
  2. Best Article BUY ADDERALL ONLINE Excellent post. I appreciate this site. Stick with it! Because the admin of this web page is working, no doubt very quickly it will be well-known, due to its quality contents.This website was how do you say it? Relevant!! Finally, I’ve found something that helped me.

    ReplyDelete
  3. Thanks for sharing these informative qtp blog. Thanks a lot..
    Very Informative Blog on QTP topics especially on QTP Automation dictionary..Very Informative blog QTP Training in Chennai.

    ReplyDelete
  4. https://k2incenseonlineheadshop.com/
    info@k2incenseonlineheadshop.com
    k2incenseonlineheadshop Buy liquid incense cheap Buy liquid incense cheap For Sale At The Best Incense Online Shop

    ReplyDelete