60 likes | 245 Views
The Event Loop. Events. Events are things that happen when your program is running There are lots of events, like: Opening the workbook Clicking a command button Typing in a text box or a spreadsheet cell Etc. etc. etc.
E N D
Events • Events are things that happen when your program is running • There are lots of events, like: • Opening the workbook • Clicking a command button • Typing in a text box or a spreadsheet cell • Etc. etc. etc. • If there is code for an event, something happens; otherwise, it is ignored
The Event Loop • In VBA, when you run your program, the system is running in a continuous loop (a Do While TRUE loop) constantly looking for events and seeing if it has code for them • When an event for which there is an event procedure occurs, the VBA system executes the procedure, and then goes back to checking • The event loop stops running when you quit the program
An Illustration • We’ll look at a demo of the Ice Cream Store that illustrates this behavior (Ice Cream Loops) • It can be run over and over to make multiple entries on the spreadsheet and in the listbox • It uses global variables to track some statistics over multiple sales