Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95

View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?


"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP




Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: Stack in Category General VBA/VB6 : Abstract Data Types from Total Visual SourceBook

Class that implements a stack with VB6 and VBA.

A stack is a restricted form of a list. All insertions and deletions occur at one end of the list. The stack data type defines three operations, Push, Pop, and Top. - Push places an item on the top of the list. - Pop removes an item from the top of the list. - Top retrieves, but does not remove, an item from the top of the list. The stack is a LIFO, or Last-In, First-Out, data type. This means that data enters and exits from the same end of the list. An example of a stack is a spring loaded plate dispenser in a cafeteria. The last plate placed in the dispenser is the first one removed. This class is implemented using an array based approach. When the array becomes full, the array is grown by the amount specified in the GrowBy property. This class supports object variables in addition to the standard text and numeric types.

Procedure List

Procedure Name



(Declarations) Declarations Declarations and private variables for the CStack class
GrowBy Property Get the amount the stack grows by when it needs to be reallocated. The default value is ten. If you know that hundreds of items are going to placed on the stack, you can increase this number to reduce the number of ReDims of the mavarData array.
Class_Initialize Initialize Set initial values
Pop Method Removes the topmost item off the stack, and places it in the varData variable
Push Method Pushes the data specified in varData on the top of the stack. If the stack is full, it grows by the amount specified by the GrowBy property.
Top Method Get the item on the top of the stack. This function differs from pop in that it does not remove the item from the stack.

Example Code for Using Class: Stack

' Example of CStack
' To try this example, do the following:
' 1. Create a new form
' 2. Create a command button named 'cmdTest'
' 3. Paste all the code from this example to the new form's module.
' 4. Run the form

Private Sub cmdTest_Click()

  Dim Stack As CStack
  Dim varData As Variant
  Dim intCounter As Integer

  Set Stack = New CStack

  ' Push 100 items onto the stack
  For intCounter = 1 To 100
    varData = "Item" & intCounter
    Stack.Push varData
  Next intCounter

  ' Pop all the items off the stack
  Do While Stack.Pop(varData)
    Debug.Print varData

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources