使用VBScript在经典ASP中收集对象? [英] Collection of objects in classic ASP using VBScript?
本文介绍了使用VBScript在经典ASP中收集对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为"Company"的类,它具有"CompanyName","CompanyCode"和"IsActive"之类的属性.此类在VBScript中.我想在经典ASP中使用VBScript存储Company对象的集合.这可能吗,如果可以,我该怎么办?
I have a class called 'Company' that has properties like 'CompanyName', 'CompanyCode' and 'IsActive'. This class is in VBScript. I want to store a collection of Company objects using VBScript in classic ASP. Is this possible, and if yes, then how would I do it?
推荐答案
您可以使用数组或字典对象:
You can use an array or a dictionary object:
数组
' 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
词典
' 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
这篇关于使用VBScript在经典ASP中收集对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文