View contents of this chapter

Writing the Code

Now we must add code for the menus just created. Each time the user selects from a menu, that selection generates a Click event. An event procedure for a control combines the control's actual name (specified in the Name property), an underscore (_), and the event name. So mnuMainExit would require a Click event named mnuMainExit_click(). The procedures for the other menu options are named accordingly. You can enter code in several ways.

  • You can enter the code one procedure at a time. From the Form Window, select the menu option you want to add code for. VB will automatically open the Code window, and type the wrapper lines of that options Click event procedure. Close the code window and select the next menu option to enter its body until you've completed the code.
  • You can select the menu option from the Code window itself. Select the menu for which you want to write the code from the Object list. Figure 6.7 shows an open Object list

Figure 6.7

  • You can open the Code window and type the code from beginning to end.
Play Sound Writing code from beginning to end takes extra time, because you must type the wrapper lines yourself.


© Universal Teacher Publications        INDEX Previous Screen Next Screen