BUG: TAB Character Can Incorrectly Cause KeyUp/KeyDown Events

Last reviewed: June 21, 1995
Article ID: Q80286
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

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.


Additional reference words: buglist1.00 buglist2.00 buglist3.00 1.00 2.00
3.00
KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrlsStd


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.