Lists in VBScript

Get rid of the dictionary and unleash the power of an ArrayList.

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

EDIT:
I see you already tried the ArrayList, but got an error. It seems your installation of the dotnet framework is not correct (System.Collections.ArrayList is part of that). Microsoft has an article about how to solve that: http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/error-code-0x80131700/3add8d80-00e0-4355-a994-8630d01c18f5

Leave a Comment