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
The Menu Editor
Before looking at menu creation, take a moment to familiarize yourself with Figure 17.1's menu components. The rest of this lesson discusses the various components that make up most Windows menus. In working with Visual Basic, you've already seen these menu components.
Figure 17.1 The menu components.
Even Visual Basic programming gurus don't always know that a menu is another control object just like a command button or a text box. After you add a menu bar to an application, the menu bar and its options are all controls that you can manage from the Properties window. Even though the menu items are regular controls with properties you can set, the programming gurus don't often know that because they use a better resource than the Properties window for creating their menus. Whereas the Properties window is great for setting normal toolbox control properties, the Menu Editor makes for a better menu-creation tool.
The Menu Editor lets you quickly and easily place menu bar items into your application by pushing command buttons and typing a few property values. The Menu Editor contains menu description tools that let you create the application's menu bar, menu commands, and shortcut access keys.
The Menu Editor is a dialog box that you access from the Form window by pressing Ctrl+E or by selecting Tools | Menu Editor from Visual Basic's own menu bar. Figure 17.2 shows the Menu Editor dialog box.
Figure 17.2 Creating a menu with the Menu Editor.
The Menu Editor creates your menu, but you still need to write event procedures that tie menu command selections to actions taken by your application. When the user selects a menu command, Visual Basic generates an event, just as it generates an event when the user clicks a command button. The only event that menu items support is the Click() event. Therefore, whether the user selects a menu option with a mouse or with a keyboard, that selection triggers a Click event.
As you'll see throughout the rest of this lesson, the Menu Editor lets you add to applications a menu bar, pull-down menu commands, separator bars (bars that help group menu options), submenus (menus that appear from other menu options), checked items, and shortcut access keystrokes. After you create the menu, you'll write event procedures for each menu option. When the user selects a menu command, that menu command's event procedure will automatically execute.
Adding an Application's Menu Bar | Next Section

Account Sign In
View your cart