What's New for Visual Basic in Visual Studio 2012

This page lists the new and enhanced features available in Visual Basic in Visual Studio 2012.

For information about how to create Windows Store apps by using Visual Studio 2012, see Develop Windows Store apps using Visual Studio 2012.

Async Feature

The new Async feature provides an elegantly simple technique to make code asynchronous. This feature makes asynchronous programming almost as straightforward as synchronous programming.

When your user interface is unresponsive or your server does not scale, it is likely that you need your code to be more asynchronous. Writing asynchronous code has traditionally involved installing a callback (also called continuation) to express the logic that occurs after the asynchronous operation finishes. This complicates the structure of asynchronous code as compared with synchronous code.

With the Async feature, you can now call into asynchronous methods without using callbacks, and without splitting your code across multiple methods or lambda expressions.

The Async modifier specifies that a method is asynchronous. When calling an Async method, a task is returned. When calling an Await statement against the task, the current method exits immediately. When the task finishes, execution resumes in the same method.

Calling an Async method does not allocate any additional threads. It may use the existing I/O completion thread briefly at the end.

For more information, see Asynchronous Programming with Async and Await (C# and Visual Basic).

Iterators

Iterators are used to perform custom iteration over collections such as lists or arrays.

An iterator uses the Yield statement to return each element in the collection one at a time. When a Yield statement is reached, the current location in code is retained. Execution is restarted from that location the next time that the iterator function is called.

You call an iterator from client code by using a For Each…Next statement.

Iterators were introduced in C# in Visual Studio 2005.

For more information, see Iterators (C# and Visual Basic).

Call Hierarchy

Call Hierarchy enables you to navigate through your code by displaying the following:

  • All calls to and from a selected method, property, or constructor.

  • All implementations of an interface member.

  • All overrides of a virtual or abstract member.

Call Hierarchy enables you to better understand how code flows and to evaluate the effects of changes to code.

Call Hierarchy was introduced in C# in Visual Studio 2010.

For more information, see Call Hierarchy.

Caller Information

This version of Visual Basic introduces a feature that makes it easy to obtain information about the caller of a method. By using Caller Info attributes, you can identify the file path of the source code, the line number in the source code, and the member name of the caller. This information is helpful for tracing, debugging, and creating diagnostic tools.

For more information, see Caller Information (C# and Visual Basic).

Global Keyword in Namespace Statements

You can now use the Global keyword in a Namespace statement. This lets you define a namespace out of the root namespace of your project.

For more information, see Namespaces in Visual Basic.

Code Editing

  • The IDE no longer automatically inserts the ByVal modifier for a parameter that doesn't specify ByVal or ByRef. ByVal is still the default if ByVal or ByRef isn't specified.

  • In automatically generated code, the IDE no longer inserts the fully qualified name for a type if the namespace is in an Imports Statement (.NET Namespace and Type) or the Imported namespaces section of the References Page, Project Designer (Visual Basic).

    Visual Studio 2012

    Private Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click
    

    Visual Studio 2010

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
    

Online Samples

You can use Visual Studio to download and install samples of full, packaged Visual Basic applications from the MSDN Code Gallery.

You can download each sample individually, or you can download a Sample Pack, which contains related samples that share a technology or topic. You'll receive a notification when source code changes are published for any sample that you download.

For more information, see Accessing Online Samples.

See Also

Concepts

What's New in Visual Studio 2012

What's New in the .NET Framework 4.5