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

Last reviewed: June 21, 1995
Article ID: Q73372
The information in this article applies to:
  • Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 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" (without the quotation marks) for the Caption.

  4. Enter "ABCD" (without the quotation marks) 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 reference words: 1.00 2.00 3.00
KBCategory: kbenv kbprg kbprb
KBSubcategory: EnvtRun


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.