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

4-7: Exercises

Exercise 4-8 (continued)

It will be best if you use string variables, perhaps named origin and destination, to which you will assign a base name depending on which option in the groups of radio buttons is selected. Where will you declare these variables - globally or locally?

The Text property of the label displaying the route (in the Journey Information groupbox) is best assigned by string operations which we have not yet covered. Essentially we need to "add" (or catenate) the string values represented by the variables origin and destination with the string " - Amundsen - " . This is achieved by the statement
lblInfo.Text = origin & " - Amundsen - " & destination
which should be used where ever the text property must be assigned its value. (We have assumed you'll use the control name lblInfo.)

The & symbol is an operator that adds, or joins together (catenates), two strings - just as the + symbol is the operator that adds two numeric values. We have seen before that the + operator when used with two string operands in fact catenates those strings. It is far preferable to use the & operator for this purpose, and you should do so from now on.

The code to manipulate the interface all occurs in the CheckedChanged events for the origin, destination and transport type radio buttons. There are fourteen such events, but you should be able to make good use of copy and paste since much of the code is the same, subject to minor naming changes. Basicly the code must disable or enable various option controls depending on the selection made, and assign the appropriate value to the string variables origin and destination before assigning a new value to the Text property of the lblInfo object.

There are many details to take care of which we leave for you to discover by careful testing as you develop the program.