16.4. Statements


In Visual Basic 2005, a complete program instruction is called a statement. Programs consist of sequences of Visual Basic 2005 statements . Each statement ends with a new line or a colon.

 Dim myString As String = "Hello World" Dim myVariable As Integer = 5 : Dim myVar2 As Integer = 7 

The colon allows you to squeeze more than one statement on a single line, but is generally considered poor programming practice because it makes for code that is harder to read and thus harder to maintain.


If your code will not fit on a single line, you may use the line continuation character, the underscore: (_) to continue a single statement on more than one line, as shown here:

 System.Console.WriteLine( _     "Freezing point of water: {0}", _     CInt(Temperatures.FreezingPoint)) 

All three lines are considered a single statement, because of the use of the line continuation character.

Be sure to add a space between any other code and the line continuation character.




Programming Visual Basic 2005
Programming Visual Basic 2005
ISBN: 0596009496
EAN: 2147483647
Year: 2006
Pages: 162
Authors: Jesse Liberty

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net