0% found this document useful (0 votes)
3 views2 pages

Visual Basic Stack Implementation Guide

Uploaded by

ramdallygrace77
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Visual Basic Stack Implementation Guide

Uploaded by

ramdallygrace77
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Imports System

Module Program
Dim stack() As Integer = {Nothing, Nothing, Nothing, Nothing, Nothing, Nothing,
Nothing, Nothing, Nothing, Nothing}
Dim basePointer As Integer = 0
Dim topPointer As Integer = -1
Dim stackFull As Integer = 10
Dim item As Integer

Dim numofitem As Integer


Dim numofitem1 As Integer
Sub Main()
Call stackelement()
[Link]()

[Link]("How many item you want to push in the stack")


numofitem = [Link]
[Link]("Push items in the stack")
For x = 1 To numofitem
item = [Link]
Call push(item)
Next

Call stackelement()

[Link]("How many item to you want to pop from the stack?")


numofitem1 = [Link]

For x = 1 to numofitem1
Call pop()
Next

Call stackelement()

End Sub

Sub push(ByVal item As Integer)


If topPointer < stackFull - 1 Then
topPointer = topPointer + 1
stack(topPointer) = item
Else
[Link]("Stack is full, cannot push.")
End If
End Sub

Sub pop()
If topPointer = basePointer - 1 Then
[Link]("stack is empty, cannot pop.")
Else
item = stack(topPointer)
topPointer = topPointer - 1
End If
End Sub

Sub stackelement()
For x = basePointer To topPointer
[Link]("The output of the stack is " & stack(x))
Next
End Sub
End Module

You might also like