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-3: Events and Sequential Processing

The statements that you write within an event (or other type of subprogram) are carried out (or executed) by the computer in sequential order. Whenever an event is activated by an action in the user interface the set of statements within the event handler (for example, those within a _Click event) is initiated. The set of statements are performed in order from the first to the last.

Thus, extending Exercise 3-1 to also calculate the volume of a cylinder you must write

txtArea.Text = System.Math.PI * txtRadius.Text * txtRadius.Text
txtVolume.Text = txtArea.Text * 2.9

in this order to first calculate the area of the base of the cylinder and then to calculate the volume of a cylinder of length 2.9. You must write the two statements in this order because you needed to set the value for txtArea.Text before you used it in the next statement. It would be incorrect to write

txtVolume.Text = txtArea.Text * 2.9
txtArea.Text = System.Math.PI * txtRadius.Text * txtRadius.Text

which reverses the order of the statements, because when the first statement is executed the txtArea.Text property most likely has no value.

Exercise 3-2 further illustrates this concept.