Click here to Skip to main content
14,030,240 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


32 bookmarked
Posted 10 Dec 2008
Licenced CPOL

A collection class for classic ASP

, 24 Jan 2012
Rate this:
Please Sign up or sign in to vote.
A class that allows the creation and manipulation of collections in classic ASP.


Classic ASP has always lacked native support for dynamic arrays and collections. This is a simple utility class that adds this functionality. It is fairly straightforward and easy to use, and provides much of the common functionality that the more advanced languages provide.


I have been writing classic ASP code for several years now, and I never was able find a collection or dynamic array class for classic ASP that provided all of the functionality of a collection in the more advanced languages. I wrote this utility class several years ago, and recently decided to publish it, seeing that there still doesn't appear to be a collection or dynamic array class out there (that I have seen) that supports all of the features this one does.

It is not limited to any type of objects for its elements, and can even have another collection as its item (so you can have a "collection of collections" if you so choose).

Using the code

The code is fairly simple and straightforward to use, as it is more or less your basic collection with a couple of advanced features.

The properties available are:

  • Object Item
  • int Count
  • Array DataArray

The methods available are:

  • int Add(Object value)
  • void AddItems(Array items)
  • void Insert(int index, Object value)
  • void Remove(Object value)
  • void RemoveAt(int index)
  • int IndexOf(Object value)
  • bool Contains(Object value)
  • void Clear()
  • string JoinData(string delimiter)
  • string ToString()
  • void CopyTo(Collection dest)
  • Collection Clone()

Shown below is a simple example of how to use the class:

dim v_col: set v_col = new Collection
v_col.Add("item 1")
v_col.Add("item 2")
v_col.Add("item 3")
v_col.AddItems(Array("item 4", "item 5"))
call v_col.Insert(2, "inserted item 3")

response.write "Count: " & v_col.Count & vbCrLf
response.write "2nd Item: " & v_col(1) & vbCrLf

v_col(1) = "item 2 edit"

response.write "Whole Collection:" & vbCrLf & v_col.ToString() & vbCrLf
response.write "Joined: " & v_col.JoinData(",")

Points of interest

The ToString() and JoinData() methods will look for a ToString() method on the items of the collection, and if they find the method, will use that to convert the item into a string. If they do not find one, they will attempt to convert the item to a string, and failing that will simply say that the item is an Object, and will show the type name of the item (e.g., "[Object: MyObject]").

I did at one time try to write a generic sorting method for this class, but never did get it to work properly with any generic object, and didn't have the time to spend getting it to work. If I ever find that I need this feature in the future, I may add it.

Revision History

  • 10 Dec 2008 - Origional version.
  • 24 Dec 2012 - Updated the download file to include the first revision suggested by ptmcomp.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer Onsharp
United States United States
I have been developing websites since 1999, and occasionally will venture into application development. I am proficient in most of the web-based languages and love what I do. I work for a small web development firm based out of Fargo, ND and plan to stay in the web development business for a long time. When I'm not programming I enjoy hiking, biking, woodworking, yard work, and the occasional computer/console game.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Manoj Kumar Choubey3-Apr-12 0:36
professionalManoj Kumar Choubey3-Apr-12 0:36 
Suggestion.NET ArrayList can be used in Classic ASP Pin
Verious31-Jan-12 12:26
memberVerious31-Jan-12 12:26 
GeneralRe: .NET ArrayList can be used in Classic ASP Pin
Flamewave431-Jan-12 14:07
memberFlamewave431-Jan-12 14:07 
GeneralMy vote of 5 Pin
$2006-Feb-11 17:25
member$2006-Feb-11 17:25 
GeneralRe: My vote of 5 Pin
AspDotNetDev24-Jan-12 7:04
protectorAspDotNetDev24-Jan-12 7:04 
GeneralFREE Classic ASP Framework Pin
josaz24-Apr-09 5:49
memberjosaz24-Apr-09 5:49 
GeneralA question in asp please help Pin
aishar21-Dec-08 23:12
memberaishar21-Dec-08 23:12 
GeneralRe: A question in asp please help Pin
Flamewave422-Dec-08 4:24
memberFlamewave422-Dec-08 4:24 
GeneralPossible improvement Pin
ptmcomp16-Dec-08 10:37
memberptmcomp16-Dec-08 10:37 
GeneralRe: Possible improvement Pin
Flamewave416-Dec-08 11:28
memberFlamewave416-Dec-08 11:28 
GeneralRe: Possible improvement Pin
dmeagor24-Jan-12 0:51
memberdmeagor24-Jan-12 0:51 
GeneralRe: Possible improvement Pin
Flamewave424-Jan-12 5:07
memberFlamewave424-Jan-12 5:07 
GeneralQuestion Pin
Verious16-Dec-08 3:18
memberVerious16-Dec-08 3:18 
GeneralRe: Question Pin
Flamewave416-Dec-08 11:15
memberFlamewave416-Dec-08 11:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190419.4 | Last Updated 24 Jan 2012
Article Copyright 2008 by Flamewave4
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid