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



The information in this article applies to:

  • Microsoft Visual Basic Standard Edition for Windows 2.0
  • Microsoft Visual Basic Standard Edition for Windows 3.0
  • Microsoft Visual Basic Professional Edition for Windows 2.0
  • Microsoft Visual Basic Professional Edition for Windows 3.0
  • Microsoft Visual Basic Standard Edition for Windows 1.0

This article was previously published under Q73372

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.

Modification Type:MajorLast Reviewed:12/12/2003
Keywords:kbprb KB73372