ASP Tutorial Lesson 7: Collections

If you want to store a list in ASP there are two popular ways, arrays and dictionaries.

Arrays are numbered lists. You can think of them as numbered boxes to put things in and you can get at the information by using the index, for example myArray(3) would get whatever was in “slot” three of myArray.

One thing to keep in mind is that arrays start with 0 (zero) as the first index. To find out how many pieces of information is stored in your array you can use ubound(arrayname).

Dimension an array

dim arrayName(x)

Dimension an array using a variable

dim arrayName()
redim preserve arrayName(x)

Dimensioning and Loading an array with values


See more info on variables in Tutorial 3.


A more advanced list is the dictionary. This stores information not against a number key but against a name. You access the value by using its name key, eg. starSigns(“July”) would return “Leo”.

Create a dictionary

set myDictionary=server.createObject(“Scripting.Dictionary”)

Add an item

myDictionary.Add “key”,”value”

Access an items value


Find if an item exists

if myDictionary.Exists(“key”) then …

Remove an item


Get an array of dictionary items


Get an array of dictionary keys



For more information on arrays, check out