Microsoft KB Archive/78335

= Scope of Line Labels/Numbers in Visual Basic for Windows =

Article ID: 78335

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q78335



SUMMARY
Line labels (and line numbers) do not follow the same scoping rules as variables and constants in Visual Basic for Windows. Line labels must be unique within each module and form. However, you can only transfer control to a line label or line number within the current Sub or Function.



MORE INFORMATION
When you attempt to define the same line label twice within a module or form, you receive the error message &quot;Duplicate label&quot;. This message means that the label is already defined in another procedure within the current module.

When you use a GOTO or GOSUB statement that names a line label defined in another procedure, you receive the error message &quot;Label not defined.&quot; This message means that the label is not defined in the current Sub or Function.

For more information about line labels, see the description of the GOTO and GOSUB statements in the &quot;Microsoft Visual Basic: Language Reference&quot; or in the Visual Basic for Windows online Help system.

Additional query words: 2.00 3.00

Keywords: KB78335

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.