Do While st.Count
Debug.Print "TOS item = " & st.Pop
Loop
-------------------------------------------
'Class Name : Cstack
'实现 Stack 操作
' this is the collection that holds the values
Dim colValues As New Collection
' add a new value onto the stack
Sub Push(value As Variant)
colValues.Add value
End Sub
' Pop a value off the stack - raise error if stack is emtpy
Function Pop() As Variant
Pop = colValues.Item(colValues.Count)
colValues.Remove colValues.Count
End Function
' Return the value on top of the stack, without popping it
' raise error if stack is empty
Function Peek() As Variant
Peek = colValues.Item(colValues.Count)
End Function
' Return the number of values in the stack
Function Count() As Long
Count = colValues.Count
End Function
===================================================================
以上是根据你问题 而引出的代码.
仅供参考!!!
你自己根据你的目的 修改一下.