Visual Basic .NET is a line-oriented language, in which line breaks generally indicate the ends of statements. However, there are times when a programmer may wish to extend a statement over several lines or have more than one statement on a single line.
To extend a
over several lines, use the line-continuation character, an
It must be the last character on its line, and it must be immediately
preceded by a space character. Lines connected in this way become a
single logical line. Here is an example:
Dim strSql As String = "SELECT Customers.CompanyName," _ & " COUNT(Orders.OrderID) AS OrderCount" _ & " FROM Customers INNER JOIN Orders" _ & " ON Customers.CustomerID = Orders.CustomerID" _ & " GROUP BY Customers.CompanyName" _ & " ORDER BY OrderCount DESC"
A line break can occur only where whitespace is allowed.
To place two or more statements on a single line, use the colon
:) between the statements, like this:
i = 5 : j = 10
The remainder of this section discusses the statements in Visual Basic .NET.
There are three
statements, which affect the
behavior of the compiler. If used, they must appear before any
declarations in the same source file. They control the compilation of
the source code in the file in which they appear. They are:
controls the manner in which strings are compared to each other. The
Option Compare [ Binary | Text ]
Binary is specified, strings ...