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 2008, the values and in some cases the names of some properties and constants have changed. When your project is upgraded to Visual Basic 2008, 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

Other Resources

Language Recommendations for Upgrading