What's New in Visual Basic Express

This topic contains information about new features and enhancements in Visual Basic 2008 Express Edition.

Support for Data

There are several new features in Visual Basic Express for developing applications that access data.

Language-Integrated Query (LINQ)

Language-Integrated Query (LINQ) is a new set of features that enable data query capabilities in Visual Basic 2008. You can use LINQ with .NET Framework collections, SQL databases, ADO.NET datasets, ADO.NET entities, and XML documents. For more information, see Using LINQ in Visual Basic ExpressGetting Started with LINQ in Visual Basic and Language-Integrated Query (LINQ).

Object Relational Designer (O/R Designer)

The Object Relational Designer (O/R Designer) assists developers in creating and editing the LINQ to SQL classes that link an application to a database. You use the O/R Designer to create classes that correspond to database objects that you can access and query in your code. For more information, see Creating LINQ to SQL Classes: Using the O/R Designer and O/R Designer Overview.

Note

The O/R Designer does not support SQL Server Compact 3.5 databases. Instead, you can use SQL Server Express. For information about obtaining SQL Server Express Edition, see the Obtaining SQL Server Express Edition section in How to: Install Sample Databases.

Microsoft SQL Server Compact 3.5

Microsoft SQL Server Compact 3.5 is a compact database that enables you to use local data in applications that you create by using Visual Basic Express. For more information, see Managing Your Records: Using Data in Your Program, Using SQL Server Compact 3.5 (Visual Studio) and How to: Add a SQL Server Compact 3.5 Database to a Project.

Language Features

There are several new language features in Visual Basic 2008, such as local type inference, object initializers, anonymous types, extension methods, and queries. Many of these features are made available to help support LINQ. You can also use many of these features to simplify the way you write code. For more information, see Visual Basic Features That Support LINQ

Local Type Inference

Local type inference enables you to declare a local variable without explicitly specifying its data type. Instead, the type is determined by the value that you assign to it when you create it. For this reason, local type inference is often referred to as implicit typing. In the following line of code, the variable is declared explicitly:

Dim totalCards As Integer = 52

By using local type inference, you can declare the variable without specifying its type, as the following code demonstrates:

Dim totalCards = 52

Even though you don't specify the type, it is determined when you write your code, at design time (early binding), instead of at run time (late binding). This is because it is inferred from the value that you assign. In both cases, totalCards is strongly typed as an Integer. For more information, see Local Type Inference.

Object Initializers

Object initializers enable you to initialize a complex object and specify its properties by using a single expression. For example, you can create an instance of an Address object and specify its properties all in the same declaration, as the following code demonstrates:

Dim homeAddress As Address = New Address With { .Street = _
    "123 Main", .City = "Kirkland", .State = "WA", _
    .PostalCode = "18033"}

Object initializers can also be used to create instances of anonymous types. For more information, see Object Initializers: Named and Anonymous Types.

Anonymous Types

The anonymous types feature enables you to create an object without specifying its data type. Instead, the compiler creates the data type definition based on the properties you specify when you create the object. These anonymous types are new types, defined by the compiler, that do not have names. For example, you can create an instance of a class (create an object), without specifying its type, by using the following code:

Dim homeAddress = New With {.Street = "123 Main",  _
    .City = "Kirkland", .State = "WA", .PostalCode = "18033"}

The type of the object is a compiler-defined class that contains the Street, City, State and PostalCode properties. The data types of the properties are determined by local type inference. For more information, see Anonymous Types.

Extension Methods

Extension methods enable you to add methods to a data type from outside the type. For example, you could add custom functionality to an existing data type, such as String.

You can learn more about extension methods in Extension Methods (Visual Basic).

Queries

Queries enable you to retrieve data from various kinds of data sources by using LINQ expressions in your code. Rather than using a query language such as SQL, you can specify clauses, such as Select, From, Order By, and Where, directly in your code. For more information, see Queries (Visual Basic), Writing Your First LINQ Query (Visual Basic), and Basic Query Operations (Visual Basic).

Lambda Expressions

Lambda expressions are inline functions that can be used wherever a delegate type is expected. A lambda expression does not have a name, and it returns a single value. An example of a lambda expression is a function that multiplies the value passed in by 2, and returns the results: Function (value As Integer) value * 2. For more information, see Lambda Expressions.

XML Integration

Visual Basic provides integrated language support for interacting with LINQ to XML. LINQ to XML enables you to create XML literal objects, load and parse XML, and use XML axis properties to access XML elements and attributes. For more information, see XML in Visual Basic.

Project Designer Support for Windows Presentation Foundation (WPF) Applications

Windows Presentation Foundation (WPF) applications have been added to Visual Basic Express. WPF is a unified programming model for building rich Windows applications that incorporate UI, media, and documents. There are two WPF project types included in Visual Basic Express:

  • WPF Windows Application (.xaml, .exe)

  • WPF Web Browser Application (.xbap, .exe)

When a WPF project is loaded into the integrated development environment (IDE), the Visual Basic Express user interface gives you access to WPF controls that can be added to the application. It also gives you access to properties that are specific to WPF applications. For more information, see Creating the Visual Look of Your Program: Introduction to Windows Presentation Foundation.

WCF Services Consumption

Windows Communication Foundation (WCF) is a new service-oriented programming model that simplifies the development of connected applications. Applications created in Visual Basic Express can communicate with (consume) existing WCF Services. For more information, see Accessing a WCF Service in Visual Basic Express.

Improvements to the IDE

There are several improvements to the integrated development environment (IDE) that help make writing code easier than ever. Several IntelliSense enhancements have been added. This includes local variable IntelliSense, Keyword IntelliSense, Expression Lists, and Syntax Tips. IntelliSense Lists are now filtered, and you can temporarily make the lists transparent so that you can see the code underneath them. For more information, see Smart Coding: Using IntelliSense to Help You Write Code.

Other improvements include error correction for namespace imports. If you use a namespace that doesn't have an imports statement, the error list will contain an option to import the namespace into you project. Additionally, the IntelliSense Code Snippets have been improved so that the variable highlighting is removed after you've customized the snippet for your code. You can learn more about IntelliSense Code Snippets in Increasing Productivity: Rapid Application Development.

ClickOnce Deployment

ClickOnce deployment now supports the deployment of WPF Web Browser Applications. WPF Web Browser Applications are hosted in a Web browser and therefore require special deployment and security settings. When you build and deploy these applications, Visual Studio will provide the appropriate user interface and default values.

For more information, see What's New in Deployment.

Power Packs Controls and Components

The Microsoft Visual Basic Power Packs 3.0 controls and components that were previously available for download are now included in Visual Basic Express. Power Packs can be used in both Visual Basic and Visual C# Windows Forms Application projects.

Included in the Power Packs are a new DataRepeater control in addition to updated versions of the previously released Line and Shape controls, the PrintForm component, and the Printer Compatibility Library.

DataRepeater Control

The new DataRepeater control enables you use standard Windows Forms controls to display rows of data in a scrollable container. This control provides more flexibility than standard grid controls.

For more information, see Introduction to the DataRepeater Control (Visual Studio).

Line and Shape Controls

The Line and Shape controls are a set of three graphical controls that enable you to draw lines, ovals, and rectangles on forms and containers at design time. These controls make it easier to enhance the look of your user interface. Line and Shape controls encapsulate many of the graphics methods that are contained in the System.Drawing namespace. This enables you to draw lines and shapes in a single step without having to create graphics objects, pens, and brushes. You can create complex graphics effects such as gradient fills by just setting some properties. These controls also provide events such as click and double-click to enable you to respond to and interact with end users.

For more information, see Introduction to the Line and Shape Controls (Visual Studio).

PrintForm Component

The PrintForm component is designed to easily print a Windows Form as you could in Visual Basic 6.0. By using the PrintForm component, you can once again lay out a Windows Form exactly how you want it and enable users to print the form as a quick report.For more information, see PrintForm Component (Visual Basic).

Printer Compatibility Library

The Printer Compatibility Library enables projects that use the Visual Basic 6.0 Printer object and Printers collection to be upgraded without requiring you to rewrite the printing logic. Just add a reference to the library, declare a Printer, and make some minor syntax changes, and the project will be able to print by using the Printers collection and Printer object as it did in Visual Basic 6.0. This version incorporates a new Write method into the Printer object. The new method enables you to print text without using a forced carriage return, like the semicolon syntax used by the Print method in Visual Basic 6.0.

For more information, see Printer Compatibility Library.

Distributing Power Packs

Also included is a bootstrapping package that enables you to easily redistribute the Visual Basic Power Packs with an application. This enables you to include the Power Packs in a ClickOnce Project or Setup Project by just clicking a check box.

For more information, see Deploying Applications That Reference Power Packs Controls.

See Also

Other Resources

Getting Started with Visual Basic Express

Visual Basic Guided Tour

Change History

Date

History

Reason

July 2008

Added section about Power Packs.

SP1 feature change.