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 (continued)

Programming the Command Buttons (continued)

You might think that this can be achieved with statements such as:

txtYear1.Text = 1
txtInterest1.Text = txtInitialCap.Text * txtRate.Text
txtCapital1.Text = txtInterest1.Text + txtInitialCap.Text

and you would indeed be on the right track, but this will not work correctly. However, let's continue as if it will so that we can see the result!

The second row of textboxes (i.e. for Year2, Interest2, and Capital2) should contain

You might try to write these statements (and also for the third row) as

txtYear2.Text = 2
txtInterest2.Text = txtCapital1.Text * txtRate.Text
txtCapital2.Text = txtInterest2.Text + txtCapital1.Text
txtYear3.Text = 3
txtInterest3.Text = txtCapital2.Text * txtRate.Text
txtCapital3.Text = txtInterest3.Text + txtCapital2.Text