'建立动态数组
Dim Arrl : Set Arrl = CreateObject("System.Collections.ArrayList")
'添加元素
Arrl.Add "Element3"
Arrl.Add "Element2"
Arrl.Add "Element1"
'查看动态数组中的元素数
WScript.Echo "动态数组中现有元素数量: " Arrl.Count
WScript.Echo "动态数组容量: " Arrl.Capacity
WScript.Echo
'遍历动态数组
Sub TraverseArrl
Dim Counter
For Counter = 0 To Arrl.Count - 1
WScript.Echo Arrl(Counter)
Next
End Sub
TraverseArrl
WScript.Echo
'动态数组排序
Arrl.Sort
TraverseArrl
WScript.Echo
'删除指定元素
Arrl.Remove("Element1")
TraverseArrl
WScript.Echo
'清空全部元素
Arrl.Clear
WScript.Echo "动态数组中现有元素数量: " Arrl.Count
WScript.Echo "动态数组容量: " Arrl.Capacity