I created a procedure called "buttonpressed" to process the numbers each time the buttons are pressed. See screen captures which are self-explanatory.
(A) Defining the global variables
(B) Calling the "ButtonPressed" procedure each time a number button is pressed:
(C) The "ButtonPressed" procedure

(D) Other buttons like the "Plus", "Equal" and "AC" buttons: