Microsoft Office Tutorials and References
In Depth Information
Using Calendar Control for Office Applications
'This is the event that is triggered by¶
'clicking day control¶
'If selected day is after the max year¶
'of this application then do not let it execute¶
If Year(CLng(DayCell.Tag)) > Me.spnYear.Max _¶
Or Year(CLng(DayCell.Tag)) < Me.spnYear.Min _¶
Then Exit Sub¶
'Set calendar value as selected day¶
'Remember day controls' tag has been set¶
'as the long value of the related date¶
Me.Value = CLng(DayCell.Tag)¶
If DayCell.ForeColor = cVarDisForeColor Then¶
'If clicked day control belongs to previous or next¶
'month then month view should be redrawn¶
'This is handled by verifying if clicked control's¶
'forecolor is the disabled day forecolor¶
Call SelectDate¶
Else¶
'Changing in same month¶
'Just change the selected date on view¶
Call MarkDate(DayCell)¶
End If¶
End Sub¶
' * * * * *¶
Public Sub SelectDate()¶
'Variable declaration¶
Dim cnt As MSForms.Label¶
Dim selStart As Long¶
Dim selEnd As Long¶
Dim disStart As Long¶
Dim disEnd As Long¶
'Counter variables¶
Dim i As Long¶
Dim j As Long¶
'The first day of the selected month¶
selStart = DateSerial(cVarCYear, cVarCMonth, 1)¶
'The last day of the selected month¶
selEnd = DateSerial(cVarCYear, cVarCMonth + 1, 0)¶
'Find which date shows for the previous month as disabled¶
disStart = selStart - Weekday(selStart) + 1¶
disEnd = DateSerial(cVarCYear, cVarCMonth, 0)¶
With Me¶
'Loop each control on UserForm¶
For Each cnt In .fraBack.Controls¶
'If control is not a day caption then reset¶
'back and fore colors¶
If cnt.Tag <> "caption" Then¶
cnt.BackColor = cVarDayBackColor¶
cnt.ForeColor = cVarDayForeColor¶
End If¶
Next cnt¶
Cmb
Search JabSto ::




Custom Search