Scope of Line Labels/Numbers in Visual Basic for Windows

ID Number: Q78335

1.00

WINDOWS

Summary:

Line labels (and line numbers) do not follow the same scoping rules as

variables and constants in Visual Basic. 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 online Help system.

Additional reference words: 1.00