VBScript to perform ArrayList operations
kw.vbs
Set ArrayList = CreateObject("System.Collections.ArrayList")
ArrayList.Add 1000
ArrayList.Add 900
ArrayList.Add 800
ArrayList.Add 700
ArrayList.Add 600
ArrayList.Add 500
ArrayList.Add 400
ArrayList.Add 300
ArrayList.Add 200
ArrayList.Add 100

print Join(ArrayList.ToArray, ", ")
ArrayList.Sort
print Join(ArrayList.ToArray, ", ")
ArrayList.Remove 1000
print Join(ArrayList.ToArray, ", ")
ArrayList.RemoveAt 0
print Join(ArrayList.ToArray, ", ")
If ArrayList.Contains(500) Then
    print "Element Present"
Else
    print "Element Not Present"
End If
ArrayList.Clear
Output
1000, 900, 800, 700, 600, 500, 400, 300, 200, 100
100, 200, 300, 400, 500, 600, 700, 800, 900, 1000
100, 200, 300, 400, 500, 600, 700, 800, 900
200, 300, 400, 500, 600, 700, 800, 900
Element Present
Example 2
kw.vbs
Set ArrayList = CreateObject("System.Collections.ArrayList")
ArrayList.Add "Apple"
ArrayList.Add "Banana"
ArrayList.Add "Cherry"
ArrayList.Add "Durian"
ArrayList.Add "Apple"
print Join(ArrayList.ToArray, ", ")
ArrayList.Sort
print Join(ArrayList.ToArray, ", ")
Output
Apple, Banana, Cherry, Durian, Apple
Apple, Apple, Banana, Cherry, Durian
Advertisement