How to create collection object in vbscript?
Here is the code, its powerful:
Option Explicit
dim list
Set list = CreateObject("System.Collections.ArrayList")
list.Add "Banana"
list.Add "Apple"
list.Add "Pear"
list.Sort
list.Reverse
wscript.echo list.Count ' --> 3
wscript.echo list.Item(0) ' --> Pear
wscript.echo list.IndexOf("Apple", 0) ' --> 2
wscript.echo join(list.ToArray(), ", ") ' --> Pear, Banana, Apple
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