In the previous post I showed how to call .NET reflection from VBA to get a list of methods of the .NET System.Collections.* classes. I wanted the method list because I felt deprived without the VBA Intellisense. Once I had the Stack's class's method list (included in listing) I could start to play around and write some sample code against the Stack class. Enjoy!
Sample System.Collections.Stack code
' Void Clear()
' Object Clone()
' Boolean Contains(?)
' Void CopyTo(?,?)
' Boolean Equals(?)
' Int32 get_Count()
' Boolean get_IsSynchronized()
' Object get_SyncRoot()
' IEnumerator GetEnumerator()
' Int32 GetHashCode()
' Type GetType()
' Object Peek()
' Object Pop()
' Void Push(?)
' Stack Synchronized(?)
' Object[] ToArray()
' String ToString()
Sub Test()
Dim obj As Object
Set obj = CreateObject("System.Collections.Stack")
obj.Push 4
obj.Push 8
obj.Push 12
Dim vLoop As Variant
For Each vLoop In obj
Debug.Print vLoop
Next
Debug.Assert obj.Peek = 12
Debug.Assert obj.Count = 3
Debug.Assert obj.Pop = 12
Debug.Assert obj.Count = 2
Debug.Assert obj.Peek = 8
Debug.Assert obj.Pop = 8
End Sub
No comments:
Post a Comment