| 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 | |
4-6: More on Nested If Statements
Exercise 4-5: Zeller's Algorithm (continued)
Finally the Zeller expression
(26M - 2) div 10 + D + Y
+ Y div 4 + C div 4 - 2C + 7777
must be evaluated. We have used the
name dValue in our code rather than D, but otherwise
m, y and c have been defined and assigned values. The div operation is the
normal name for an integer division (i.e. divide but keep only the whole number
as in 15 div 6 = 2). In Visual Basic the div operator is \. Use z for the variable name to which this expression value is
assigned.
Next the value of the Zeller expression must be divided by 7 to find the
remainder. The remainder on division by 7 can only be one of 0 to 6. If it is 0
the day is Sunday, 1 is Monday etc. Thus, depending on the value of this
remainder, we assign one of the weekday names to the Text
property of the label object that displays the Zeller result. This can be done
with a sequence of the type
If ... ElseIf ... ElseIf ...
... Else ... End If
Use lblZeller for the
label object name.