Asp Dictionary Object


Methods Properties Asp Dictionary Object Example

The Asp dictionary object

allows you to store information in data key, item pairs.Later we can retrieve

the information by providing the dictionary with key word.The following code

illustrates how to create a Dictionary object:


Dim objDictionary

Set objDictionary = CreateObject(Scripting.Dictionary)

objDictionary.Add “animal”, “Elephant”

objDictionary.Add “bird”, “Craw”



strkey = “Fruit”

strvalue = “Banana”

objDictionary.Add strkey,strvalue


Asp Dictionary Object Methods



Method Syntax Description
Add objDictionary.Add

key, item

Adds a key

and item pair to a Dictionary object

Remove object.Remove(key) Removes a

key, item pair from a Dictionary object

RemoveAll objDictionary.RemoveAll The RemoveAll

method removes all key, item pairs from a Dictionary object.

Exists objDictionary.Exists(key) Returns True

if a specified key exists in the Dictionary object; False if it does not

Items objDictionary.Items Returns an

array containing all the items in a Dictionary object.

Keys objDictionary.Keys Returns an

array containing all existing keys in a Dictionary object.


Asp Dictionary Object Properties



Property Syntax Description
Count objDictionary.Count Returns the

number of items in a collection or Dictionary object. Read-only

Key objDictionary.Key(key)

= newkey

Sets a key

in a Dictionary object

Item objDictionary.Item(key)

= newitem


Sets or returns

an item for a specified key in a Dictionary object. 

CompareMode objDictionary.CompareMode

= compare


Sets and

returns the comparison mode for comparing string keys in a Dictionary object.



dim objdictionary

set objdictionary=createobject(“scripting.dictionary”)

objDictionary.Add “animal”, “Elephant”

objDictionary.Add “bird”, “Craw”

Response.write(“all data stored in dictionary”&”<hr>”)


retrieve it”)


response.write(“Value stored with key of

animal is “&strvalue&”<hr>”)


set new value to animal”)

if objdictionary.exists(“animal”) then


End if

response.write(“The new value of animal

is “&objdictionary.item(“animal”)&”<br>”)


set change key for Craw from bird to C”)

if objdictionary.exists(“bird”) then


response.write(“The  value stored with

key C is “&objdictionary.item(“C”))

end if




Leave a Comment