Export (0) Print
Expand All

Declaration Syntax for Visual Basic 6.0 Users 

Visual Basic 2005 introduces several changes related to the declaration of programming elements.

Multiple Variable Declaration

Visual Basic 2005 revises simultaneous declaration of several variables for simplification.

Visual Basic 6.0

In Visual Basic 6.0, you can declare variables of different types in the same statement, but you must specify the data type of each variable or it defaults to Variant. The following example shows multiple declarations and their resulting data types:

Dim I, J As Integer             ' I is Variant, J is Integer. 
Dim L As Integer, M As Integer  ' L is Integer, M is Integer. 
Dim N As Integer, X As Double   ' N is Integer, X is Double. 

Visual Basic 2005

In Visual Basic 2005, you can declare multiple variables of the same data type without having to repeat the type keyword. The declarations equivalent to those in the preceding example are as follows:

Dim I                           ' I is Object. 
Dim J As Integer                ' J is Integer. 

Or

Dim I As Object, J As Integer   ' I is Object, J is Integer. 
Dim L, M As Integer             ' L is Integer, M is Integer. 
Dim N As Integer, X As Double   ' N is Integer, X is Double. 

External Procedure Declaration

Visual Basic 6.0

In Visual Basic 6.0, when you declare a reference to an external procedure with the Declare statement, you can specify As Any for the data type of any of the arguments and the return type. The As Any keywords disable type checking and allow any data type to be passed in or returned.

Visual Basic 2005

Visual Basic 2005 does not support the Any keyword. In a Declare statement, you must specifically declare the data type of every argument and the return if Option Strict is On. This improves type safety. You can overload your procedure declaration to accommodate various argument data types. You cannot overload only on return types, but you can use the argument type overloads to vary the return type, or you can turn Option Strict Off.

Line Label Declaration

Visual Basic 6.0

In Visual Basic 6.0, a line number can directly precede a statement on the same line, without any separating character.

Visual Basic 2005

Visual Basic 2005 requires that every line label be followed by a colon (:). A statement can optionally follow the colon on the same line, or the line label and colon can stand alone on the line.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft