Sams Teach Yourself Visual Basic 6 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Introduction
- Who Should Read This Book
- What This Book Will Do for You
- Can This Book Really Teach Visual Basic in 24 Hours?
- What You Need
- Files on the Visual Basic Distribution CD-ROM
- Conventions Used in This Book
- Enough! Time Is Ticking!
- Part I: Introducing Visual Basic
- Hour 1. Visual Basic at Work
- Hour 2.Analyzing Visual Basic Programs
- Hour 3.Controls and Properties
- Hour 4.Examining Labels, Buttons, and Text Boxes
- Part II: Coding the Details
- Hour 5.Putting Code into Visual Basic
- Hour 6.Message and Input Boxes
- Hour 7.Making Decisions
- Hour 8.Visual Basic Looping
- Part III:Putting Code to Work
- Hour 9.Combining Code and Controls
- Hour 10.List Boxes and Data Lists
- Hour 11.Additional Controls
- Hour 12.Dialog Box Basics
- Part IV:Programming with Data
- Hour 13.Modular Programming
- Hour 14.Built-In Functions Save Time
- Hour 15.Visual Basic Database Basics
- Hour 16.Printing with Visual Basic
- Part V:Sprucing Up Programs
- Hour 17.Menus and Visual Basic
- Hour 18.The Graphic Image Controls
- Hour 19.Toolbars and More Graphics
- Hour 20.Writing Correct Applications
- Part VI:Advancing Visual Basic Applications
- Hour 21.Visual Basic and ActiveX
- Hour 22.Object Basics
- Hour 23.Distributing Your Applications
- Hour 24.Online Visual Basic
- Part VII:Appendixes
- Appendix A.Operator Precedence
- Appendix B.Answers
- Appendix C.Using the CD-ROM
Naming Menu Options
You should follow a standard naming convention when naming menu options.
The event procedures within any Visual Basic application reference menu options by their menu option names. Preface all menu items, both menu bar and pull-down menu items, with the mnu prefix so that you can easily distinguish menu commands from variables and from the other controls as you work within the application's code.
As you add pull-down options to the menu bar items, preface each option with the mnu prefix as well as the name of the menu bar command, and then append the name of the pull-down menu's item. The File | Exit item would be named mnuFileExit, View | Normal would be named mnuViewNormal, and so on. The names then clearly describe the menu items that they represent. If a submenu appears, append its item name to the parent's name (for example, mnuViewNormalFull).
Follow these steps to complete the creation of a menu bar:
- Click the Menu Editor's Next command button to inform Visual Basic that you want to add the next item. The lower window's highlight bar drops down to the next line in preparation for the next menu item. The buttons right above the lower window control the addition, insertion, and deletion of menu items from the menu you are building.
- Type &Edit at the Caption text box and press Tab. Name this second menu bar item mnuEdit. Click the Next command button to prepare the Menu Editor for the next menu bar item.
- Type &View and press Tab to move the focus to the Name text box. Type mnuView and select Next to prepare for the final menu item.
- Type &Help and press Tab to move the focus to the Name text box. Type mnuHelp. Your screen should look like the one in Figure 17.4.
Figure 17.4 The menu bar is now complete with four options.
Close the Menu Editor by pressing Enter or clicking the OK command button. Immediately, Visual Basic displays the new menu bar across the top of the application's Form window, as shown in Figure 17.5. The menu bar is the result of your efforts with the Menu Editor.
Figure 17.5 The Form window's new menu bar.
Obviously, the menu is incomplete. The menu bar exists, but no options pull down from the menu bar. You're now ready to add the individual pull-down options to the menu. The next section explains how to complete the File pull-down menu.
Adding Pull-Down Menu Options | Next Section

Account Sign In
View your cart