Thursday, August 7, 2008

QTP: using dictionary object

Set d = CreateObject(”Scripting.Dictionary”)
d.Add “a”, “Anil” ‘ Add some keys and items.
d.Add “b”, “Dhruvan Aaryan”
a = d.Items ‘ Get the items.
For i = 0 To d.Count -1 ‘ Iterate the array.
s = s & a(i) & “
” ‘ Create return string.
Msgbox s

Exists Method
Returns true if a specified key exists in the Dictionary object, false if it does not.

If d.Exists(”c”) Then
Msgbox “Specified key exists.”
Msgbox “Specified key doesn’t exist.”
End If

No comments: