PRB: DEL Key Behavior Depends on Text Box MultiLine Property

Last reviewed: August 11, 1997
Article ID: Q77737

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

Pressing the DEL key in a multiline text box generates a KeyPress event for that text box with an ASCII code of 8 for the key. In a standard text box, no KeyPress event is generated for the DEL key.

STATUS

This behavior is by design. It is inherent to Windows and is not specific to Microsoft Visual Basic for Windows.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Place a text box on a form.

  2. Set the MultiLine property for the text box to True.

  3. Add the following code to the text box KeyPress event:

       Sub Text1_KeyPress (keyAscii as Integer)
            debug.print keyAscii  ' This will print the generated ASCII
                                  ' code to VB's Immediate window.
       End Sub
    
    

  4. Execute the program and press the DEL key while the focus is on the text box. An "8" will be printed in the Immediate window.

If the text box's MultiLine property is set to false, no KeyPress event occurs and nothing is printed to the Immediate window when you press the DEL key. This behavior is standard for Windows multiline text boxes.
Keywords          : PrgCtrlsStd kbcode kbprb kbtlc
Version           : 1.0 2.0 3.0
Platform          : WINDOWS
Issue type        : kbprb


================================================================================


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: August 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.