Collection of objects in classic ASP using VBScript?
1 answer
You can use an array or a dictionary object:
Array
' create an array with a fixed size
dim companies(2)
' fill the array with the companies
set companies(0) = Company1
set companies(1) = Company2
set companies(2) = Company3
' iteration example 1
dim company
for each company in companies
response.write company.CompanyName
next
' iteration example 2
dim i
for i = 0 to ubound(companies)
response.write companies(i).CompanyName
next
Vocabulary
' create a dictionary object
dim companies
set companies = server.createObject("Scripting.Dictionary")
' add the companies
companies.add "Key1", Company1
companies.add "Key2", Company2
companies.add "Key3", Company3
' iteration example
dim key
for each key in companies.keys
response.write key & " = " & companies.item(key).CompanyName
next
+8
source to share