This documentation is archived and is not being maintained.

Upgrade Recommendation: Use Constants Instead of Underlying Values

When writing code, try to use constants rather than relying on their underlying values. For example, if you are maximizing a form at run time, use:

' GOOD: Constant name
Me.WindowState = vbMaximized

rather than:

'BAD: Underlying value
Me.WindowStyle = 2
'BAD: Variable
Me.WindowStyle = X

Likewise, use True and False instead of -1 and 0.

In Visual Basic .NET, the values and in some cases the names of some properties and constants have changed; for example, the value of True changes from -1 to 1. When your project is upgraded to Visual Basic .NET, most constants are changed automatically for you; however, if you use underlying values or variables instead of the constant names, many cases cannot be upgraded automatically. Using constant names minimizes the number of modifications you have to do.

See Also

Language Recommendations for Upgrading