ARTICLE

Line Continuation in VB.NET

Posted by Mahesh Chand Articles | Visual Basic Language May 03, 2010
This article discusses the line continuation keyword and syntax in VB.NET language.
 
Reader Level:

Line Continuation

Line continuation is needed when you want to spread out a single line of code into multiple lines. If you do not use a line continuation, you will get a syntax error in Visual Studio 2010.

A line continuation is represented by a single underscore ("_ ") character with a combination of a white-space before the underscore and immediately followed by a whitespace. A line continuation must also have at least one character after the second whitespace, something like following:

SomeCharacter WhiteSpace UnderScore WhiteSpace SomeCharacter

The code snippet in Listing 1 creates a function and uses line continuation in function definition as well as in the code inside the function.

    Function LineContinuationSnippet(ByVal NumberOne As Integer, _

                                     ByVal NumberTwo As Integer) _

                                     As Integer

        If (NumberOne > NumberTwo Or _

            NumberOne = NumberTwo) Then

            Return NumberOne

        Else

            Return NumberTwo

        End If

 

    End Function

Listing 1

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Team Foundation Server Hosting
Become a Sponsor