O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Scope of Variables

Declaring variables at procedure level (for instance, within the Sub and Function methods, or Property procedures, which are covered in Chapter 9) has an effect on their scope. While in VBA and Visual Basic 6.0, for example, variables within procedures are still valid throughout that procedure from the moment they are declared, in .NET versions of Visual Basic, they are valid from the moment they are declared only within the code block in which they are defined. A “code block” in this context basically means a construct that encapsulates code in some way; for example, If ... Then ... Else blocks, For ... Next or Do ... Loop loops, or even With blocks, among others. The Visual Studio IDE makes it relatively easy to see where ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required