Dictionary
object:
- The Dictionary object stores information in name/value pairs.
- The Dictionary object might seem similar to Arrays, however, the Dictionary object is a more desirable solution to manipulate related data.
-
Keys are used to identify the items in a Dictionary object
-
You do not have to call ReDim to change the size of the Dictionary object
-
When deleting an item from a Dictionary, the remaining items will automatically shift up
-
Dictionaries cannot be multidimensional, Arrays can
-
Dictionaries have more built-in functions than Arrays
-
Dictionaries work better than arrays on accessing random elements frequently
-
Dictionaries work better than arrays on locating items by
their content
The Dictionary object's properties:
-
CompareMode-Sets or returns the comparison mode for
comparing keys in a Dictionary object
-
Count-Returns the number of key/item pairs in a Dictionary
object
-
Item-Sets or returns the value of an item in a Dictionary
object
-
Key-Sets a new key value for an existing key value in a
Dictionary object
Methods of Dictionary object:
-
Add-Adds a new key/item pair to a Dictionary object
-
Exists-Returns a Boolean value that indicates whether a
specified key exists in the Dictionary object
-
Items-Returns an array of all the items in a Dictionary
object
-
Keys-Returns an array of all the keys in a Dictionary
object
-
Remove-Removes one specified key/item pair from the
Dictionary object
-
RemoveAll-Removes all the key/item pairs in the Dictionary
object
Example:
<html>
<body>
<script language="vbscript" type="text/vbscript"> Dim d Set d=Server.CreateObject("Scripting.Dictionary") d.Add "re","Red" d.Add "gr","Green" d.Add "bl","Blue" d.Add "pi","Pink" Response.Write("The value of key gr is: " & d.Item("gr")) </script> </body> </html>
-
The value of key gr
is: Green
No comments:
Post a Comment