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-6: More on Nested If Statements

Exercise 4-5: Zeller's Algorithm (continued)

Open a new Visual Basic project and design the interface, remembering to name the textbox, command buttons, and two label objects (displaying ??? in Figure 4-5) with the conventional prefixes.

The Reset button should clear the textbox and assign focus to it, and set the Text properties of the two label objects used for output display back to the string ??? The Exit button should simply end the program, of course.

The click event of the Compute button does all the work here of course. It should first validate that the user has input a date string using the IsDate function and then convert the string to a Date, assigning it to a variable declared to be of Date type. Then the code should extract the day, month and year from this Date variable, assigning each to appropriately named Integer variables.

This is done using the DateAndTime.Day, DateAndTime.Month and DateAndTime.Year functions, as in

theDate = Convert.ToDateTime(txtDate.Text)
dValue = DateAndTime.Day(TheDate)
mValue = DateAndTime.Month(TheDate)
yValue = DateAndTime.Year(TheDate)

Notice the choice of variable names - they will be used in subsequent pages. They will all have to be declared as Integer of course.