PRB: Moving Off 'Sub' Doesn't Create 'End Sub'Last reviewed: October 30, 1995Article ID: Q129938 |
The information in this article applies to:
SYMPTOMSIf you use the mouse or arrow keys to move off the statement:
Sub X ()the End Sub statement is not generated, and the Sub X() statement appears as part of the subroutine that follows it.
CAUSEThis is by design. The purpose of this behavior is to give you control over whether or not an End Sub is automatically generated. There are cases when it is desirable not to have an End Sub generated.
RESOLUTIONLeaving the Sub line by pressing the ENTER key automatically generates the appropriate End Sub. This also adds the End Sub where one did not exist if you previously left the line by using the mouse or arrow keys.
STATUSThis behavior is by design.
MORE INFORMATIONVisual Basic version 4.0 supports conditional compilation and you may want to take advantage of that to create more than one Sub statement for a single subroutine depending on various conditions.
#if WIN32 then Sub MySubWin32version(x) #else Sub MySubWin16version(x,y) #endif ' ... End SubIn this case, you would not want two End Sub statements generated for your two Sub statements. If you move off the first Sub statement with the ENTER key and the second Sub statement with the mouse or arrows, this procedure is generated correctly. As Visual Basic cannot anticipate which case will require End Sub and which will not, you are given explicit control.
Steps to Reproduce Behavior
|
Additional reference words: 4.00 vb4win vb4all
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |