Chapter 3- Data Types and Operators Boolean Expressions Page 2 3 4

Introduction

The If Statement Page 2 3 4 5 6 7 8 9
Arithmetic Operations Page 2 3 4 5 6 Boolean Operators and Nested If Statements Page 2 3 4 5 6 7
Events and Sequential Processing Page 2 3 4 5 More Examples Page 2 3 4 5 6 7 8 9 10 11 12
Datatypes and Conversions Page 2 3 4 5 6 7 Using Check Box and Option Controls Page 2 3 4 5 6 7 8 9 10
Variable Declarations - Local and Global Page 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Exercises Page 2 3 4 5 6 7 8
Chapter 4- Selection Statements Review Questions
Introduction

3-5: Variable Declarations

Introduction

Generally programs need to store data in the computer's memory (RAM) in order to manipulate it. So far we have relied on the properties of control objects (primarily the Text property) to store data. For example, we calculated the interest amount in Exercise 3-2, and assigned it to the txtInterest1.Text property, and then used that property value to calculate the new capital amount as CDbl(txtInitialCap.Text) + CDbl(txtInterest1.Text). The properties of objects are in fact names for memory locations in the computer's memory, but they are associated with particular objects. However, this is quite limiting in general. It is not sensible to place a control object on a form every time you want to store a value!

Programming languages provide facilities for the programmer to create names for places in the computer's memory (RAM) where data can be stored. Rather than creating numerous GUI objects in order to use their properties to store data one uses such names.

These names are generically called variables. Creating a variable essentially sets aside a certain amount of computer memory and defines a name that refers to that memory.

In this section we'll see how to define variables and use them to store data. They are called variables because the contents of the computer memory that they name may be changed, i.e. a new value may be assigned to the "variable". This means that a new value is stored in the computer memory at the place specified by the variable name.