PRB: Can't Use Multiple & (for Access Keys) in VB Menu Control

ID: Q73372


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for Windows, versions 2.0, 3.0
  • Microsoft Visual Basic programming system for Windows, version 1.0


SYMPTOMS

When creating a menu control that uses multiple ampersand characters (&) to mark the access keys in the caption (for example, &a&b&c&d), the menu will appear with an underline under the character after the last &. However, the access key will respond to the character following the first &.


WORKAROUND

Use a single ampersand character per caption.


STATUS

This behavior is by design in the Windows operating environment.


MORE INFORMATION

Steps to Reproduce Behavior

  1. From the File menu, choose New Project (ALT+F+N).


  2. From the Window menu, choose Menu Design Window (ALT+W+M).


  3. Enter &A&B&C&D for the Caption.


  4. Enter ABCD for the CtlName.


  5. Choose the Done button.


  6. Click the menu item ABCD on Form1.


  7. Enter the statement Print "ABCD" in the click event for the menu item ABCD as follows:
    
       Sub ABCD_Click ()
           Print "ABCD"
       End Sub 


  8. Run the program.


When the program is run, the D in the menu caption will be underlined, but the menu responds to ALT+A, not ALT+D.

Additional query words: 2.00 3.00

Keywords :
Version : WINDOWS:1.0,2.0,3.0
Platform : WINDOWS
Issue type :


Last Reviewed: January 25, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.