| Chapter 3- Data Types and Operators | Boolean Expressions Page 2 3 4 |
| 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-2: Arithmetic Operators
A program is made up of statements that conform to the rules of the particular programming language. You have already met some statements - for example
Button1.Height = 40We have also discussed some of the basic rules that such statements conform to. For example, Chapter 2 introduced the notion of values, assignment of values (to properties of an object), the 'words' used in the language, and the dot notation as in object.property.
The equals (=) sign is formally known as an operator - the assignment operator in fact. There are many symbols representing the operators used in programming languages. The most common, apart from the assignment operator, are those used for arithmetic.
To add, subtract, multiply and divide two values the operators are +, -, * and /. These operators are
used to build an expression, which when the program runs
will have a value that may be assigned to an object
property or a variable,
or used in other
ways.
A variable is essentially a name you use to represent a value. The value,
calculated by an expression using operators and other values, is assigned to the
variable using the assignment operator. You'll see this frequently in the
future.
A typical expression might be
Button1.Height / 2
and if the Height
property of a button
called Button1 has the value 300 the expression will
have the value 150. This value could then be assigned to some other object
property as in
Button2.Height = Button1.Height / 2
The Height property is an integer representing the
vertical dimension in pixels of an object (the button in this case).
This assignment statement would cause the height of a second button, Button2, to have the specified value. This is just hypothetical usage. You'll develop actual examples shortly.