Back to Final Project website


Lesson 2 Variables and Scope p. 34 - 40

  1. Declaring a variable causes VB to _________________ a spot in memory for the value of the variable.
  2. Use the _________________ statement to declare variables.
  3. Always choose the best ___________ ____________ to contain the type of data you need to use in your program.
  4. Data stored as a variable can be processed much faster than data stored in _______ ____________ ________________ ________________ _______________.

 

Data Type

Stores…

Prefix

Example

Byte

 

byt

BytAge

byt

 

Logical values: True or False

bln

blnCancel 

blnOpen

Currency

15 digits left of decimal, 4 digits to the right

 

 

Integer

 

 

 

 

int

intCount

intNumber

Long

Large integer, whole numbers, no decimals or fraction

Negative 2 billion to pos 2 billion

 

 

 

Floating point decimal numbers up to six decimal places

sng

sngRate

sngDecimal

 

Double

Larger numbers, up to 15 decimal places

 

 

Date

 

Dte

dteBirth

dteFile

 

 

Text up to 65k alphanumeric characters, must be in ___________

str

strName

strAddress

strCity

 

 

Stores different data types

vnt

vntUnknown

vntGeneric

 

5.      ______________________ are useful data in your program with a value that does not change.

 

Scope

  1. The _________________ of a variable is its reach. This describes the lifetime of a variable and what parts of the program are ______________ of it.
  2. Variables declared at the procedure level are called __________________ variables. They are only seen and recognized by the ___________________ or _________________ in which they are declared.
  3. Variables declared at the ____________________ ________________ level are called form level variables. These variables need to be seen by various ________________ or __________________. Form level variables stay in memory until the _____________________ ends.
  4. Variables declared at _________________ level are called global variables. These are seen by more than just one _______________.
  5. At the module level there is no difference between _______________ and ______________.
  6. Variables declared in a module can be Private, they are seen by the whole ______________.
    1. Private strMyPrivateVariable as _______________
  7. ________________ variables are available to all _______________.
    1. Public strMyPublicVariable as _________________ .