Chapter 3


Home

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Chapter 14

Chapter 15

Table of Contents


Variables, Expressions, and Statements

Variables are names of values contained in memory locations. Variables are named with the InterCap method. You build variable names by joining words or portions of words. Capitalize the first letter of each word or word portion.

You can use these arithmetic operations in Visual Basic: exponentiation (^), multiplication (*), division (/), addition (+), and subtraction (-). You can remember the order in which these operations are executed with "Please Excuse My Dear Aunt Sally:"

  • Parentheses
  • Exponentiation
  • Multiplication and Division in order, from left to right
  • Addition and Subtraction in order, from left to right

    The assignment statement evaluates an expression on the right side of the equal sign and assigns that value to the variable on the left side.

      variable = expression

    The assignment statement is also used to assign values to properties of objects.

      object.property = expression

    Program break points are set from the toolbar. A break point stops program execution at a particular line. While the program is halted, you can print or change the values of variables from the Debug window.

    The Single-Step button in the toolbar executes one line of code with each click. After a line is executed, the program halts, allowing you to check and alter values in the Debug window.

    The Variant type is capable of representing any of the other types.

    The SetFocus method, a built-in subroutine, shifts the focus from control to control. txtTime.SetFocus shifts the focus to the object named txtTime.