Dim mintTopOfStackIndex As Integer
Dim arrStack() As String Sub Stack_Init () '************************** 'initialize stack 'note:must be called before ' pushing or popping '************************** mintTopOfStackIndex = 0 '0 - no entries End Sub Function Stack_Pop () '************************** 'pop a value from the stack 'note: ' returns "" if nothing ' is on stack '************************** 'check for no entries on stack If (mintTopOfStackIndex < 1) Then Stack_Pop = "" Exit Function End If 'pop off of stack Stack_Pop = arrStack(mintTopOfStackIndex) 'decrement counter by one mintTopOfStackIndex = mintTopOfStackIndex - 1 ReDim Preserve arrStack(mintTopOfStackIndex) End Function Sub Stack_Push (ByVal strValue) '************************** 'push strValue onto stack '************************** 'increment counter by one mintTopOfStackIndex = mintTopOfStackIndex + 1 'push on stack ReDim Preserve arrStack(mintTopOfStackIndex) arrStack(mintTopOfStackIndex) = strValue End Sub |