' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Collections

Public Class MyStack
    Private Dim list As ArrayList = new ArrayList()
    Public Sub Push(v As String)
        list.Add(v)
    End Sub
    Public Function Pop() As String
        Pop = list.Item(list.Count - 1)
        list.RemoveAt(list.Count - 1)
    End Function
    Public Function Peek() As String
        Peek = list.Item(list.Count - 1)
    End Function
    Public Function MidRemove(ix As Integer) As String
        MidRemove = list.Item(ix)
        list.RemoveAt(ix)
    End Function
End Class

Module Main
    Sub Main()
        Dim stack As MyStack = new MyStack()
        stack.push("a")
        stack.push("bb")
        stack.push("ccc")
        stack.push("dddd")
        Console.WriteLine(stack.MidRemove(0))
        Console.WriteLine(stack.Peek())
        Console.WriteLine(stack.Peek())
        Console.WriteLine(stack.Pop())
        Console.WriteLine(stack.Pop())
        Console.WriteLine(stack.Pop())
    End Sub
End Module
