crash while execution of opengl(visual basic) program

Hi
I’m trying to build datastructure (queue/stack/tree) in opengl. when I execute it working properly(working procedure when I click 1 it goes to stack then by using mouse I can insert/remove/exit lly click 2 for queue click 3 for tree)

problem is think that when I’m working in stack inbetween when I press 2 it shifts to queue with some error lly when I press 3 it goes to tree with some sort of errors appears like some scattered line without any operation in tree

so provide some sort of soln

1)while operating on some datastructure(ds) it should not jump to another ds though I press any number(eg when I'm operating in stack when I press 2 It should not jump to queue so button 2 and 3 should not be worked)
2)when I go back to main menu the operation done before should be reset to beginning (ie:think that I have done some operation say stack full by inserting blocks when I come back to main menu by using m/M key, the operation done before ie stack full should be reset to stack empty)

the code is something like messy I’m a beginner to this opengl so plz help me
source codehttps://github.com/punith21/qst.cpp/blob/master/qst.cpp