For a = 1 To 37
f("Day" & a + gOffset).Visible = False
f("Text" & a + gOffset).Visible = False
[B][COLOR="darkgreen"] f("DBox" & a + gOffset).Visible = False '******************************Added[/COLOR][/B]
f("date" & a + gOffset) = Null
f("day" & a + gOffset) = Null
Next
'Modify the Date Format so that it is equivilent
'to the US Date Format since this function wants
'to work in that format. This way, any Country
'date format will work.
dayOne = Format(DateValue(m & "/1/" & Y), "mm/dd/yyyy")
workdate = dayOne
'--------------------------------------------------------------
'The code here is new. The Offset was not quite getting acquired
'properly but I didn't like the method anyway. Now, the Offset is
'gathered by the WeekDay name as indicated by the first 3 letters
'within the WeekDay Labels at the top of Calendar. This way it
'doesn't matter which day is indicated as the beginning of the week.
'Normally, Sunday is the beginning of a calendar week but you have
'decided to use Monday as the beginning. This function did not offset
'properly if that was the case. Now it does. It doesn't matter which
'is the first day of the week. If you put Thusday (or Thu) as the
'first day of the week, this function will still offset properly.
'This makes things very very flexable and far more accurate.
WkDay = Format(dayOne, "dddd")
For a = 1 To 7
If LCase(Left$(f.Controls("WeekDayLabel" & a).Caption, 3)) = _
LCase(Left$(WkDay, 3)) Then
gOffset = a - 1: Exit For
End If
Next a
'---------------------------------------------------------------
'The old method to get Offset.
' gOffset = Weekday(dayOne) - 1
For a = 1 To LenMonth(dayOne)
f("Day" & a + gOffset).Visible = True
f("Text" & a + gOffset).Visible = True
[B][COLOR="darkgreen"] f("DBox" & a + gOffset).Visible = True '*************************Added[/COLOR][/B]
f("date" & a + gOffset) = workdate
workdate = workdate + 1
f("day" & a + gOffset) = a
Next