Scope of Line Labels/Numbers in Visual Basic for Windows

ID: Q78335


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for Windows, versions 2.0, 3.0
  • Microsoft Visual Basic programming system for Windows, version 1.0


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 "Duplicate label". 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 "Label not defined." 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 "Microsoft Visual Basic: Language Reference" or in the Visual Basic for Windows online Help system.

Additional query words: 2.00 3.00

Keywords :
Version : WINDOWS:1.0,2.0,3.0
Platform : WINDOWS
Issue type :


Last Reviewed: January 25, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.