Share via


Upgrade Recommendation: Avoid Legacy Keywords

Because they have been removed from the language, you should avoid using the following keywords in Visual Basic 6.0 projects that may be upgraded to Visual Basic 2008.

Keyword

Explanation

Def<type>

In previous versions of Visual Basic, DefBool, DefByte, DefInt, DefLng, DefCur, DefSng, DefDbl, DefDec, DefDate, DefStr, DefObj and DefVar are used in the declarations section of a module to define a range of variables as a certain type. For example, DefInt A-C defines all variables beginning with the letter A, B, or C as an integer. Instead of using Def<type> statements, you should explicitly declare variables.

Computed GoTo/GoSub

Computed GoTo/GoSub statements take this form:

On x GoTo 100, 200, 300

These are not supported in Visual Basic 2008. Instead, you should use If statements, or Select Case constructs.

GoSub/Return

GoSub and Return statements are not supported in Visual Basic 2008. In most cases you can replace these with functions and procedures.

Option Base 0|1

The Option Base statement was used to specify the default lower bound of an array as either 0 or 1. This statement has been removed from the language since Visual Basic 2008 natively only supports arrays with a zero lower bound. Non-zero lower bound arrays are supported through the Compatibility library.

VarPtr, ObjPtr, StrPtr

VarPtr, VarPtrArray, VarPtrStringArray, ObjPtr and StrPtr are undocumented functions used to get the underlying memory address of variables. These functions are not supported in Visual Basic 2008.

LSet

In Visual Basic 6.0, the LSet statement can be used to assign a variable of one user-defined type to another variable of a different user-defined type. This functionality is not supported in Visual Basic 2008.

See Also

Other Resources

Language Recommendations for Upgrading