Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

initialize a new collection 1

Status
Not open for further replies.

voodoojon

Technical User
Dec 18, 2003
107
GB
I get an error when I try to initialize a new instance of the collection class:

Public Col
Set Col = New Collection.

As far as I can see, this causes an error because you can only use Set [object] = New [Classname] if Classname is a Class ... End Class defined somewhere in the script. But how, then, do I tell VBScript that I want my object to be a collection object?

I'm probably missing something really simple here.
 
I don't think VBScript allows you to create collections by itself.

The Scripting (WSH) library has a Dictionary object that's creatable for this reason. The IE DOM supports creation of new items, attributes, and collections of atributes under an item. That probably isn't what you were after though.

I'm not sure what you'd do in other script hosts such as various Office programs, 3rd party programs, or home-built script hosts.

In general the Dictionary object might be your best bet if it'll do what you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top