你需要自己写个 Stack 来实现.
例如:
Dim st As New CStack
Dim oPic(2) As StdPicture '使用 StdPicture 对象来保存图片
Set oPic(1) = LoadPicture("C:\1.bmp")
Set oPic(2) = LoadPicture("C:\2.bmp") ' push two values on the stack
st.Push oPic(1)
st.Push oPic(2)
Debug.Print "Count = " & st.Count
Debug.Print "Peek = " & st.Peek
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
===================================================================
以上是根据你问题 而引出的代码.
仅供参考!!!
你自己根据你的目的 修改一下.
例如:
Dim st As New CStack
Dim oPic(2) As StdPicture '使用 StdPicture 对象来保存图片
Set oPic(1) = LoadPicture("C:\1.bmp")
Set oPic(2) = LoadPicture("C:\2.bmp") ' push two values on the stack
st.Push oPic(1)
st.Push oPic(2)
Debug.Print "Count = " & st.Count
Debug.Print "Peek = " & st.Peek
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
===================================================================
以上是根据你问题 而引出的代码.
仅供参考!!!
你自己根据你的目的 修改一下.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货