Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

What's New in the Visual Basic Language 

Visual Basic 2005 introduces new language features, including loop continuation, guaranteed resource disposal, mixed access properties, unsigned and nullable data types, operator overloading, partial and generic types, custom events, and Common Language Specification (CLS) compliance checking.

This page lists features that are new to the Visual Basic language with Visual Basic 2005. For a discussion of features and functionality that have changed from earlier versions, see Language Changes for Visual Basic 6.0 Users.

Continue Statement

Visual Basic now supplies a Continue statement, which immediately skips to the next iteration of a Do, For, or While loop. For more information, see How to: Skip to the Next Iteration of a Loop and Continue Statement (Visual Basic).

Visual Basic 6.0 Form Access

Visual Basic now allows you to refer to a defined form, such as Form1, by using its class name, instead of explicitly creating an instance of it. For more information, see How to: Access a Form.

IsNot Operator

Visual Basic now furnishes an IsNot operator, with which you can avoid using the Not and Is operators in an awkward order. For more information, see How to: Test Whether Two Objects Are the Same and IsNot Operator.

TryCast Operator

Visual Basic now provides the TryCast type conversion operator that returns Nothing if the attempted conversion fails, unlike CType and DirectCast which both throw an InvalidCastException error. For more information, see TryCast.

Using Statement

Visual Basic now offers a Using...End Using block to ensure disposal of a system resource when your code leaves the block for any reason. For more information, see How to: Dispose of a System Resource and Using Statement (Visual Basic).

Explicit Zero Lower Bound on an Array

Visual Basic now permits an array declaration to specify the lower bound (0) of each dimension along with the upper bound. For more information, see How to: Specify a Zero Lower Bound on an Array.

Properties with Mixed Access Levels

Visual Basic now allows you to declare a property with different access levels on its Get and Set procedures. For more information, see How to: Declare a Property with Mixed Access Levels.

Unsigned Types

Visual Basic now supports unsigned integer data types (UShort, UInteger, and ULong) as well as the signed type SByte. For more information, see How to: Call a Windows Function that Takes Unsigned Types, How to: Optimize Storage of Positive Integers With Unsigned Types, UInteger Data Type, ULong Data Type (Visual Basic), UShort Data Type (Visual Basic), and SByte Data Type (Visual Basic).

Nullable Types

Visual Basic now supports extensions of value types that can take either their normal values or a null value. A null value is useful for indicating that a variable has no defined value because the information is not currently available. For more information, see Value Types and Reference Types and Value Types that Might Not Have a Defined Value.

Operator Overloading

Visual Basic now allows you to define a standard operator (such as +, &, Not, or Mod) on a class or structure you have defined. For more information, see How to: Use a Class that Defines Operators, How to: Define an Operator, and Operator Statement.

Code Separation using Partial Types

Visual Basic now provides a mechanism to allow the integrated development environment (IDE) to separate generated code from your authored code into separate source files. Most of the time, you only have to deal with the code you wrote. For more information, see Partial (Visual Basic).

Generic Types

Visual Basic now supports type parameters on generic classes, structures, interfaces, procedures, and delegates. A corresponding type argument specifies at compilation time the data type of one of the elements in the generic type. For more information, see Generic Types in Visual Basic.

Custom Events

Visual Basic now allows you to have greater control over the detailed behavior of events. You can declare custom events by using the Custom keyword as a modifier for the Event statement. In a custom event, you specify exactly what happens when code adds or removes an event handler to or from the event, or when code raises the event. For examples, see Event Statement, How to: Declare Events That Conserve Memory Use, and How to: Declare Events That Avoid Blocking. To maintain backward compatibility with existing code, the Custom keyword is not a reserved keyword.

Compiler Checking Options

Visual Basic 2005 introduces new compiler checking options. The /nowarn and /warnaserror (Visual Basic) options provide more control over how warnings are handled. Each one of these compiler options now takes a list of warning IDs as an optional parameter, to specify to which warnings the option applies.

  • CLS Compliance Checking

Visual Basic now generates a warning for each line of code that contains any specification or operation that the Common Language Specification (CLS) does not support.

  • Uninitialized Variable Checking

Visual Basic now generates a warning for each potentially uninitialized variable. A variable has this status if there is at least one possible execution path that does not assign any value to the variable before using it.

For more information, see Configuring Warnings in Visual Basic.

See Also

Community Additions

ADD
Show:
© 2015 Microsoft