Use the Code window to write, display, and edit Visual Basic code. You can open as many Code windows as you have modules, so you can easily view the code in different forms or modules, and copy and paste between them.
You can open a Code window from:
- The Project window, by selecting a form or module, and choosing the View Code button.
- A UserForm window, by double-clicking a control or form, choosing Code from the View menu, or pressing F7.
You can drag selected text to:
- A different location in the current Code window.
- Another Code window.
- The Immediate and Watch windows.
- The Recycle Bin.
Displays the name of the selected object. Click the arrow to the right of the list box to display a list of all objects associated with the form.
Lists all the events recognized by Visual Basic for a form or control displayed in the Object box. When you select an event, the event procedure associated with that event name is displayed in the Code window.
If (General) is displayed in the Object box, the Procedure box lists any declarations and all of the general procedures that have been created for the form. If you are editing module code, the Procedure box lists all of the general procedures in the module. In either case, the procedure you select in the Procedure box is displayed in the Code window.
All the procedures in a module appear in a single, scrollable list that is sorted alphabetically by name. Selecting a procedure using the drop down list boxes at the top of the Code window moves the cursor to the first line of code in the procedure you select.
Dragging this bar down, splits the Code window into two horizontal panes, each of which scrolls separately. You can then view different parts of your code at the same time. The information that appears in the Object box and Procedures/Events box applies to the code in the pane that has the focus. Dragging the bar to the top or the bottom of the window or double-clicking the bar closes a pane.
Margin Indicator Bar
A gray area on the left side of the Code window where margin indicators are displayed.
Procedure View Icon
Displays the selected procedure. Only one procedure at a time is displayed in the Code window.
Full Module View Icon
Displays the entire code in the module.