Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
6Activity
0 of .
Results for:
No results containing your search query
P. 1
VB Script Objects

VB Script Objects

Ratings: (0)|Views: 29 |Likes:
Published by G.C.Reddy
VB Script Objects; It describes Dictionary object ant Its Methods & Properties with examples. It is useful for QTP Testes as well as web developers.
VB Script Objects; It describes Dictionary object ant Its Methods & Properties with examples. It is useful for QTP Testes as well as web developers.

More info:

Published by: G.C.Reddy on May 12, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

08/14/2010

pdf

text

original

 
VB Script Objects
************************************************
Visit:
for QTP Scripts and Other Info
************************************************
Dictionary Object
 
Dictionary Object that stores data key, item pairs.A Dictionary object is the equivalent of a PERL associative array/HashVariable. 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 retrievean individual item and is usually an integer or a string, but can beanything except an array.
Creating a Dictionary Object:Set objDictionary = CreateObject("Scripting.Dictionary")
 
Dictionary Objects Methods:Add Method
 Adds a key and item pair to a Dictionary object
Exists Method
Returns true if a specified key exists in the Dictionary object, false if itdoes not.
1
 
Items Method
Returns an array containing all the items in a Dictionary object.
Keys Method
Returns an array containing all existing keys in a Dictionary object.
Remove Method
Removes a key, item pair from a Dictionary object.
RemoveAll Method
The RemoveAll method removes all key, item pairs from a Dictionaryobject.
 Example:
Dim citiesSet cities = CreateObject("Scripting.Dictionary")cities.Add "h", "Hyderabad"cities.Add "b", "Bangalore"cities.Add "c", "Chennai"
Dictionary Objects Properties:Count Property
Returns the number of items in a collection or Dictionary object. Read-only.
CompareMode Property
Sets and returns the comparison mode for comparing string keys in aDictionary object.
Key Property
Sets a key in a Dictionary object.
Item Property
Sets or returns an item for a specified key in a Dictionary object. Forcollections, returns an item based on the specified key. Read/write.
2
 
 Examples:1) add Elements
 
AddDictionary
Set
 
objDictionary
 
=
 
CreateObject("Scripting.Dictionary")objDictionary.Add
 
"Printer
 
1",
 
"Printing"
 
objDictionary.Add
 
"Printer
 
2",
 
"Offline"objDictionary.Add
 
"Printer
 
3",
 
"Printing"
 
2) Delete All Elements fromDictionary
Set
 
objDictionary
 
=
 
CreateObject("Scripting.Dictionary")objDictionary.Add
 
"Printer
 
1",
 
"Printing"
 
objDictionary.Add
 
"Printer
 
2",
 
"Offline"objDictionary.Add
 
"Printer
 
3",
 
"Printing"colKeys
 
=
 
objDictionary.KeysWscript.Echo
 
"First
 
run:
 
"For
 
Each
 
strKey
 
in
 
colKeys
 
Wscript.Echo
 
strKeyNextobjDictionary.RemoveAllcolKeys
 
=
 
objDictionary.KeysWscript.Echo
 
VbCrLf 
 
 
"Second
 
run:
 
"For
 
Each
 
strKey
 
in
 
colKeys
 
Wscript.Echo
 
strKeyNext
3) Delete One Element from a Dictionary
Set objDictionary = CreateObject("Scripting.Dictionary")objDictionary.Add "Printer 1", "Printing"objDictionary.Add "Printer 2", "Offline"objDictionary.Add "Printer 3", "Printing"
3

Activity (6)

You've already reviewed this. Edit your review.
1 hundred reads
omjsr liked this
minemotorola liked this
SIZETHESPY liked this
satishkumar360 liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->