ID Number: Q76558
1.00
WINDOWS
Summary:
Menu items can be given shortcut keys that allow you to access the
menu item without pulling down a menu. However, some of the common
keyboard editing keys produce ASCII key codes that are identical to
those provided for shortcut keys. This means that menu items can be
activated by typing certain characters while the focus is on a Visual
Basic control, such as on a text box.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
The Visual Basic Menu Design window allows you to assign shortcut keys
that will activate a menu item without having to pull down a menu.
Normally, only the combination specified as the shortcut key will
activate the menu item.
Shortcut keys are typically defined as either control-key combinations
or SHIFT-control-key sequences. The problem is that several normal
keyboard keys (such as BACKSPACE, TAB, and ENTER) produce ASCII codes
identical to certain menu shortcut control keys. A list of potential
conflicts is presented below:
ASCII Values Menu Shortcut Keys Editing Keys
------------ ------------------ ------------
08 CTRL+H BACKSPACE
09 CTRL+I TAB
13 CTRL+M ENTER
The conflict occurs because each character is examined to determine if
it is a shortcut key before being passed to the text box. If the ASCII
code corresponds to a menu shortcut key, the menu item is executed,
and the text box is never notified of the keystroke.
It is recommended that you not use the menu shortcut keys listed above
on any form that contains a text box that accepts user input.
Steps to Reproduce Problem
--------------------------
1. Start Visual Basic.
2. Draw a text box on the initial form.
3. Design a menu with a menu title and one menu item below it. Assign
CTRL+M as the menu item's shortcut key. (To assign the control-key
shortcut CTRL+M to a menu command, select from the Accelerator box in
the Menu Design window.)
4. Insert the following line into that menu item's Click procedure:
MsgBox "Menu item activated"
5. Run the program.
6. Enter a few characters into the text box and press ENTER.
After pressing ENTER in the text box, the MsgBox statement should be
executed, indicating that control was passed to the menu item.
Additional reference words: 1.00