 | 09/05/2010 |  |
|
.asp Dictionary information
In .asp, it is helpful to use Dictionaries. In particular, a Dictionary can be used when you need to return more than one value from a function.
The Dictionary is a variable that must be created as an object. First you Dim it like any other variable, and then you set it as a Dictionary object.
Dim Dictionary
set Dictionary = Server.CreateObject("Scripting.Dictionary")
Add key/value pairs with
Dictionary.Add key, value
Pass them back as the output of a function by
FunctionName = Dictionary
It is not necessary to tell the function that the result will be a dictionary, you just establish and manage the dictionary variable as a dictionary and use it as an argument to the function return.
Read them with
Calling function
Dim ResultDictionary
Then, unlike othe functions, you use the set keyword to let the function know you expect an object
set ResultDictionary = YourFunctionReturningADictionary
TheValue = ResultDictionary.Item("Key")
______________________________________________________________________
Category