TDBHolidayX Object > Features of the TDBHolidayX Object |
This section describes the following TDBHolidayX object features:
Holidays and weekends
Setting up weekends
Setting up holidays
Holidays and Weekends
This section describes how rest days can be handled in the TDBHolidayX object.
Rest days can be treated in two ways: they can be treated either as weekends, or as holidays. Weekends are defined by designating which weekdays will become rest days, such as Saturdays and Sundays, or Sundays and Mondays, and so on. Holidays are defined by designating a particular day as a rest day.
Setting Up Weekends
The TDBHolidayX object supports weekday rests, or weekends, such as Sunday, by using the WeekRests() property. The WeekRests() property actually defines which week of the month for a particular weekday will be a weekend.
Think of the WeekRests() as a matrix table where weekdays are columns and weeks of month are rows. Now, in the table just pick the weeks that you would like to handle as a weekend. Once this is setup, the same table will be used throughout the rest of the months. The WeekRests() is a property array, starting from Sunday - elements 1 through 7 holds each weekdays information. The following table shows how to set the weekday rests:
WeekRests() |
Description |
---|---|
-1 |
All |
0 |
None |
1 |
First week |
2 |
Second week |
4 |
Third week |
8 |
Fourth week |
16 |
Fifth week |
32 |
Last week in month |
Since multiple weeks for a weekday can be set as a weekend, the numbers can to be combined. The following sample will add weekends to the TDBHolidayX object.
Example Title |
Copy Code
|
---|---|
' Create an instance of TDBHolidayX object. Dim HolidayMgr As New TDBHolidayX ' Set weekends for Saturday and Sunday. ' Sunday (all). HolidayMgr.WeekRests(1) = -1 ' Saturday (first & third). HolidayMgr.WeekRests(7) = 1 Or 4 |
This sample sets the first and third week for Saturdays, and all weeks for Sundays to be weekends.
Refer to the next section, Setting up holidays, to see how individual days can be set as holidays.
In the previous section we covered how weekends can be setup, and in this section we will talk about how individual holidays are handled in the object. The TDBHolidayX object handles holidays in groups like the national holiday, company holidays or vacations, and so on. A holiday style can be added to the control by using the Add or the AddObj method in the HolidayStyles collection, and individual holidays can then be added to the style using the Days collection. The following sample shows how easily this can be done.
Example Title |
Copy Code
|
---|---|
' Add a holiday style to the object. HolidayMgr.HolidayStyles.Add , "NH", "National Holiday" ' Set color to use for holidays, and add holidays. With HolidayMgr.HolidayStyles("NH") .Override = dbiOverrideNextDay ' Add holidays here. .Days.Add "2/11", "Holiday1", CDate("1998/2/11") .Days.Add "3/21", "Holiday2", CDate("1998/3/21") .Days.Add "4/29", "Holiday3", CDate("1998/4/29") End With |
The above sample added a holiday style called “National Holiday” to the HolidayStyles collection property. 3 holidays (2/11, 3/21, 4/29) were added to the style.
To have the holiday style take effect in the object, the holiday style key must be specified in the UseStyles property. This property handles all the holiday styles to process in the object.
Example Title |
Copy Code
|
---|---|
HolidayMgr.UseStyles = "NH"
|
When defining the holiday style to use, the key name (not the holiday description) must be used. In this case, the holiday key name is "NH".
For more information see HolidayStyle Object Properties.