Option Explicit
'建立堆栈
Dim Stk : Set Stk = CreateObject("System.Collections.Stack")
Stk.Push "Element1"
Stk.Push "Element2"
Stk.Push "Element3"
'查看堆栈中的元素数
WScript.Echo "堆栈中的元素数: " Stk.Count
WScript.Echo
'遍历堆栈
Sub TraverseStk
Dim ArrStk : ArrStk = Stk.ToArray
Dim Counter
For Counter = 0 To UBound(ArrStk)
WScript.Echo ArrStk(Counter)
Next
End Sub
TraverseStk
WScript.Echo
'元素出栈
WScript.Echo Stk.Pop
WScript.Echo "---"
TraverseStk
WScript.Echo
'清空堆栈
Stk.Clear
WScript.Echo "堆栈中的元素数: " Stk.Count