BUG: TAB Character Can Incorrectly Cause KeyUp/KeyDown Events (80286)



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 Q80286

SYMPTOMS

Under certain circumstances, the TAB key may generate either or both a KeyDown or KeyUp event for a form or control. The Language Reference for Visual Basic version 1.0 states on page 160 that KeyDown and KeyUp events are not generated for the TAB key. This is normally true.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base 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 generates a KeyUp and/or KeyDown event. 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 is created by default.
  2. Draw a command button on Form1.
  3. Add the following code to 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 that may be corrected in future versions, you should not write code that depends upon this behavior.

Modification Type:MajorLast Reviewed:12/12/2003
Keywords:kbbug KB80286