![]() ![]() ![]() ![]() ![]() Gravitybox Schedule Primer
Page 28
1998-2004 Gravitybox Software LLC
Code to block out all weekend days may be constructed with a simple loop. The
following code loops through all the dates on a schedule and defines the weekend days
as NoDrop zones.
Dim i As Long
Dim lLoopCount As Long
Dim dtCurDate As Date
'Loop through how many days?
lLoopCount = DateDiff("d", Schedule1.MinDate,
Schedule1.MaxDate)
'Perform loop
For i = 0 To lLoopCount - 1
'Get the current date
dtCurDate = DateAdd("d", i, Schedule1.MinDate)
'If the date is Saturday (Weekday function = 7)
'or Sunday (Weekday function = 1)
'Then add it to our no drop collection
If (Weekday(dtCurDate) = 1) Or _
(Weekday(dtCurDate) = 7) Then
Call Schedule1.NoDropAreas.Add(dtCurDate)
End If
Next I
When the schedule is displayed and these dates come into the viewable window, they
will be a special color defined by the color of the added NoDrop object. This will allow
the user to easily see that this is not a valid section of the schedule.
Figure 1.5
|