This section takes a quick look at some of the coding commands available from the Edit, Debug, and Run menus. You’ll find that many of these commands are initially hidden. To make them available, a Code window must be open. Let’s continue with the three-text-boxes project. Double-click anywhere on UserForm1 to open the Code window for UserForm1, displaying the first and last line for the UserForm_C!ick event procedure.
Commands for Editing Code
The commands in the Edit menu, shown just below, include indispensable editing tools, some of which you’ve already used. You experienced their convenience,when they did your typing for you by completing words and popping up lists so you could choose what to enter next. Also included in the Edit menu are the Undo and Redo, Cut,
Copy and Paste, and Find and Replace commands, which are standard in many Windows applications—I’m sure you’re familiar with these already. Notice also the Indent and Outdent commands, which allow you to quickly change the left-alignment position of your code lines.
Commands for Debugging Code
The Debug menu commands, shown just below, allow you to run your code line-by-line while you watch the values of variables change. When you know that sections of your code are correct, then you can set breakpoints to allow your code to run as normal until it encounters a breakpoint, at which point execution stops and you can step through the untested sections of code one statement at a time. There is also a Compile ACADProject command that translates all of your code into a format that can be executed by your computer. This will make your application run faster, because Visual Basic normally translates the code into intermediate p-code one line at a time as it is required.
Commands for Running Code
The Run menu commands execute your code.
The Run commands evolve dynamically in several ways, according to whatever form or module is active, and whether or not the application is already in Run mode. For example, the Run Sub/UserForm command is only available when a UserForm is open; at other times, the command changes to Run Macro.
As indicated by the icons beside these menu commands, they all have a corresponding toolbar button. Each one also displays a ToolTip when you mouse over it. The ToolTip that pops up “evolves” in exactly the same way as the menu command:
If the application is running and stops at a breakpoint or at an error in your code, the Run command changes to let you continue from the breakpoint, as shown here:
The Reset command, when executed, causes the IDE to tidy up any memory usage, and prepares everything so that the application can run again without any interference from values stored during previous runs.