O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Erl Property

Class

Microsoft.VisualBasic.Information

Syntax

Erl

Return Value

An Integer containing the line number

Description

Indicates the line number on which an error occurred

Rules at a Glance

  • Erl returns the line number only if one has been provided in the source code.

  • If the error occurs on a line that does not have a line number, Erl returns 0.

Programming Tips and Gotchas

  • Erl is not affected by compiler settings. Compiling with the /debug- switch does not prevent Erl from accurately reporting the line number.

  • Line numbers are rarely used in modern VB code. In VB.NET, line numbers are labels that must be followed by a colon.

  • Although programmers have been requesting an error-handling function that reports the line number on which an error occurred, Erl has one major limitation: namely, it requires that the developer assign a line number to source code lines in advance.

  • Erl is not new to VB.NET. It was an undocumented and little known function in previous versions of Visual Basic (and of QBasic as well).

VB.NET/VB 6 Differences

In VB 6, line numbers are distinct from labels, and do not require that any symbol (other than white space) separate them from their lines’ source code. In VB.NET, line numbers are labels that must be followed by a colon.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required