| 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)
Using the Weekday and WeekdayName Functions
To calculate the day of the week using the built-in Visual Basic functions is, of course, a lot simpler. The function DateAndTime.WeekdayName takes an integer argument with a value between 1 and 7 and returns a string, being the name of the day of the week. To obtain such a number from a date you use the DateAndTime.Weekday function, which takes an argument of Date type. Read about these functions in the Object Browser, noting that they each have optional parameters that we do not need to specify for our particular task.
Thus the statement to assign a value to the other label object is
lblFunction.Text = DateAndTime.WeekdayName(DateAndTime.Weekday(TheDate))
where the result returned by the function Weekday(TheDate) is used as the argument for the function WeekdayName.