Implicit Line Continuation in VB 2010

An new feature that is of interesting to us VB Revit add-in developers is the

implicit line continuation
that
was added in Visual Basic 2010.

In prior versions of VB, all statements that continue beyond the end of the line have to be explicitly marked using an underscore ‘_’ character.
Since some of the Revit API method signatures force rather long lines, this can become a bit overwhelming.
This is what it might look like in VB 2008:


''' <summary>
''' Hello World #2 - simplified without full namespace.   
''' </summary>
<Transaction(TransactionMode.Automatic)> _
Public Class HelloWorldSimple
  Implements IExternalCommand
 
  Public Function Execute( _
    ByVal commandData As ExternalCommandData, _
    ByRef message As String, _
    ByVal elements As ElementSet) _
    As Result _
    Implements IExternalCommand.Execute
 
    TaskDialog.Show("My Dialog Title", "Hello World Simple!")
    Return Result.Succeeded
 
  End Function
 
End Class

With the new implicit line continuation feature, many of the underscores can be omitted in VB 2010:


<Transaction(TransactionMode.Automatic)>
Public Class HelloWorldSimple
  Implements IExternalCommand
 
  Public Function Execute(
    ByVal commandData As ExternalCommandData,
    ByRef message As String,
    ByVal elements As ElementSet) _
    As Result _
    Implements IExternalCommand.Execute
 
    TaskDialog.Show("My Dialog Title", "Hello World Simple!")
    Return Result.Succeeded
 
  End Function
 
End Class

Note that two of the underscores still remain;
the implicit line continuation is only available after certain syntax elements, such as after a comma or an opening parenthesis, or before a closing parenthesis.

Here is an interview with Doug Rothaus of the Visual Studio User Education team describing it:

Updated Visual Basic Add-in Wizard

Here is an updated VB version of the Visual Studio

Revit 2012 add-in wizard
making
use of the implicit line continuation:

The only change I made was to remove the line continuation underscores wherever possible.

For the C# version, please refer to the

original post
.

Visual Studio Line Length Guide Line

Another complementary Visual Studio feature of special interest to all of us who have to limit the line length of our source code due to one reason or another is the

guide-line for Visual Studio
pointed
out yesterday by Augusto and Kean.

Since I have the same issue as Kean, having to limit my source code line length strictly to fit into the blog post format, I installed it as described and verified that it works well.


Comments

2 responses to “Implicit Line Continuation in VB 2010”

  1. Does anyone know of a decent book that can help me write in C# ? I have hit a bit of a wall with Autodesk and need to strt using some of the plugins.

  2. Dear Steve,
    I mentioned one possibility in
    http://thebuildingcoder.typepad.com/blog/2010/10/cairo-and-free-net-books.html
    Here is the direct link I mentioned there, to “7 Freely available E-Books/Guides I found essential for .NET Programmers and Architects”:
    http://amazedsaint.blogspot.com/2010/09/7-freely-available-e-booksguides-i.html
    They are maybe a bit advanced. Here is one recommendation for beginners:
    http://thebuildingcoder.typepad.com/blog/2009/07/a-net-language-learning-resource.html
    I would also assume that Kean Walmsley has some good advice for you:
    http://through-the-interface.typepad.com/through_the_interface
    Look at his topics DevTV and AutoCAD.NET, for example, they point to lots of beginner’s tutorials.
    The DevTV series helps you get started with .NET in both AutoCAD and Revit:
    http://thebuildingcoder.typepad.com/blog/2010/10/revit-2011-devtv.html
    I think there was an introductory class on generic C# and .NET programming at Autodesk University 2010, but I can’t find it right now, I’m afraid.
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading