1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 4 - Working With Menus and Dialog Boxes - Part 1

By , About.com Guide

4 of 4

But wait! There's More!

A little more experimentation reveals that, at least in Windows XP (and perhaps in all versions of Windows), you don't have to actually CODE access keys at all. Try this:

1 - Create a new Windows Application

2 - Add a MainMenu component and then a single top level menu and two menu items under it. For example:

~~~~~~~~~~~~~~~~~~~~~~~~~
Whatever <- Top Level menu item
  A Menu Item <- First sub menu item
  B Menu Item <- Second sub menu item
~~~~~~~~~~~~~~~~~~~~~~~~~

3 - Add MsgBox statements to the Click events for each sub menu item to indicate when the event is executed.

DO NOT add access key identifiers (&) or do anything else.

Now run the application. Notice that if you ...

Press and release the Alt key
press W, then A, you get the first MsgBox
press W, then B, you get the second MsgBox

You don't need to specify access keys. The first letter of the string in the Text property is used!

To figure out more technical problems, you need to understand what's happening a little more thoroughly than just being able to work the Visual Studio tools. Chapter 4 has two major topics where a "deeper level" of understanding will be necessary in a lot of cases:

  • Working with dates and times
  • Working with colors

In both of these cases, as long as you stick to the default formats, you won't have any problems. But in both of them, you'll discover that getting more customized results requires that you know more about it. So let's look at them a little more ...

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2009 About.com, a part of The New York Times Company.

All rights reserved.