BUG: Invalid outside Sub Error When Copy or Paste to GeneralLast reviewed: June 21, 1995Article ID: Q79240 |
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
SYMPTOMSAn "Invalid outside Sub or Function" error occurs in the VB.EXE environment under the following conditions:
CAUSEThe problem occurs when you copy a subprogram to the general Declarations section with Sub subname() and End Sub (or Function functionname () ... End Function) included. If you change the name of the original or copied Sub (or Function), the error "Invalid outside Sub or Function" will occur at run time. After the error occurs, the Sub or Function header of the copied Sub will be missing.This problem occurs because the Sub or Function that was changed is treated as the entry of a new procedure. The body of the Sub or Function and the End Sub (or End Function) statement are treated as an existing part of the general Declarations section and are left behind. The behavior is identical when the Sub (or Function) that was copied is deleted. The Sub (or Function) heading of the copy, residing in the general Declarations section, is treated as a new Sub or Function entry.
WORKAROUNDFollow these steps to work around the problem:
STATUSMicrosoft 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
Steps to Reproduce Problem
Print "Hello" End SubAs illustrated above, the first line of the subprogram, Sub Test2 (), is missing. This is because Visual Basic treats the name change as a new Sub entry and established a new subprogram (Test2). The Procedure box will contain Test2 as a subprogram. Visual Basic considers the remaining part of Test2 (the code fragment above) to be an existing part of the general Declarations section.
|
Additional reference words: buglist1.00 buglist2.00 buglist3.00 1.00 2.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |