Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create collection object in vbscript?

what should be the parameter for create object the following code

dim a
set a=CreateObject("Collection") //getting a runtime error saying ActiveX 
//component can't create object: 'Collection
a.add(CreateObject("Collection"))
a.Items(0).Add(1)
MsgBox(a.Items(0).count)
MsgBox(a.Items(0).Item(0))
like image 875
Onnesh Avatar asked May 19 '10 10:05

Onnesh


People also ask

How do I declare an object in VBScript?

When you want to use a COM object in a VBScript file, you need to create an instance of, or instantiate, that object. Instantiating a COM object is a two-part process that uses either the CreateObject or GetObject function and the Set statement. where "Scripting. FileSystemObject" is the ProgID of the FSO object.

What is a collection of object?

A set is a collection of objects. The objects are called the elements of the set. If a set has finitely many elements, it is a finite set, otherwise it is an infinite set.

What is meant by collection object in VB net?

VB.NET implements a special object called the Collection object that acts as a container for objects of all types. In fact, Collection objects can hold other objects, as well as nonobject data. In some ways, the Collection object is an object-oriented version of the Visual Basic array.

How to use collection in vb6?

You can use the Visual Basic Collection class to access a collection item by using either a numeric index or a String key. You can add items to a collection object either with or without specifying a key. If you add an item without a key, you must use its numeric index to access it.


1 Answers

how about a Dictionary

Set coll = CreateObject("Scripting.Dictionary")
coll.Add 0, "5"
coll.Add 4, "10"
coll.Add "textkey", "15"
MsgBox coll.Count
MsgBox coll.Item(0)
MsgBox coll.Item(4)
wholeColl = ""
for each key in coll.Keys
  wholeColl = wholeColl & key & " = " & coll.Item(key) & ", "
next
MsgBox wholeColl
like image 148
Tester101 Avatar answered Sep 24 '22 11:09

Tester101