Declaring and Naming Variables

The first line of code is a Dim, or Dimension, statement, used for dimensioning (or declaring) variables. When your program declares a variable, it is, in essence, telling Visual Basic, “Set aside a memory location that will be used to store variable information; I will reference it by this name.” The last two words in the Dim statement tell Visual Basic what type of information you plan to store—in this case, integer numbers. This information helps determine how much memory is to be set aside for the variable.

Note

Variables also can be declared with other keywords besides Dim, such as Public and Private. For more details, see the section in Chapter 8, “Managing Program Tasks with Procedures,” called “Understanding ...

Get Special Edition Using Microsoft® Visual Basic® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.