PRB: Line Continuation Character (_) Causes Event Concatenation

Last reviewed: March 31, 1997
Article ID: Q165975
The information in this article applies to:
  • Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0

SYMPTOMS

The code window shows each event procedure of a control individually in the default procedure view. Adding a space and a line continuation character (an underscore "_") after the line of code preceding the End Sub statement results in the following event of the same control to appear. If the Full Module View check box in the Editor Tab of the Options dialog box is clicked, the line separating the two procedures disappears.

STATUS

This behavior is by design.

MORE INFORMATION

The line continuation character causes the next line of code to be concatenated with the code line containing the line continuation character. Visual Basic then considers the procedure containing the line continuation character as part of the next event procedure.

Steps To Reproduce Behavior

  1. Start Visual Basic, or, if it is already running, click New Project from the File menu.

  2. Copy and paste the following code to the Form1 Code Window:

          Private Sub Form_Click()
    
             MsgBox "world"
          End Sub
    
          Private Sub Form_Load()
             MsgBox "hello"
          End Sub
    
       You should see only the Form_Load event in the code window.
    
    

  3. In the Form_Click event, type a space followed by a line continuation character (_) after the code line for the message box in the Form_Click procedure event. The code should look like the following:

          Private Sub Form_Click()
    
             MsgBox "world" _
          End Sub
    
       After you press the ENTER key, the Form_Click and the Form_Load
       procedure events appear in the same procedure event. If the Full Module
       View checkbox is checked, then the line separating the procedures
       disappears.
     
    
    	


Keywords : EnvtDes kbenv kbusage vb4all vb4win kbprb
Version : 4.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: March 31, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.