TAB Character Can Incorrectly Cause VB KeyUp/KeyDown Events

ID Number: Q80286

1.00

WINDOWS

buglist1.00

Summary:

The "Microsoft Visual Basic: Language Reference" manual for version

1.0 states on page 160 that KeyDown and KeyUp events are not generated

for the TAB key. This is normally true, but under certain

circumstances, the TAB key may generate either or both of these events

for a form or control.

Microsoft has confirmed this to be a problem with the Microsoft Visual

Basic programming system version 1.0 for Windows. We are researching

this problem and will post new information here as it becomes available.

More Information:

The TAB key is normally used to switch focus from one control to

another in the predefined tab order. This action does not normally

produce a KeyDown or KeyUp event. However, if there is not another

control that can accept the focus, pressing TAB will generate KeyUp

and/or KeyDown events. This problem manifests itself in several

situations:

- A form with no controls

- A form with only one control

- A form with all controls disabled (or all except one)

- A form with all controls invisible (or all except one)

- A combination of the last two above

Steps to Reproduce Problem

--------------------------

1. Start Visual Basic, or, if it is already running, choose New

Project from the File menu. Form1 will be created by default.

2. Draw a command button on Form1.

3. Copy the following line into the KeyDown event for the command

button:

Form1.Print KeyCode

4. Run the program.

5. Press the TAB key. The character "9" will appear on the form. The

character "9" is the ANSI code for the TAB character.

6. End the program.

The TAB key should never produce a KeyDown or KeyUp event. However,

because this is a problem with Visual Basic version 1.0, and may be

corrected in future versions, you should not write code that depends

upon this behavior.

Additional reference words: 1.00