Microsoft Office Tutorials and References
In Depth Information
Using Calendar Control for Office Applications
'An object array is needed to handle every¶
'day controls' events¶
Dim dayArray() As clsCalendar¶
' * * * * *¶
Private Sub SetDefaults()¶
'Day cells¶
'Create Controls class object to create new controls on the fly¶
Dim objControl As New clsCalendar¶
Dim objDays As clsCalendar¶
Dim lbl As MSForms.Label¶
'Counter variables¶
Dim i As Integer¶
Dim j As Integer¶
With Me¶
'There are 6 rows and 7 columns for a month view¶
For i = 1 To 6¶
For j = 1 To 7¶
ReDim Preserve dayArray((j - 1) + ((i - 1) * 7))¶
Set objDays = New clsCalendar¶
Set lbl = .fraBack.Controls.Add("Forms.Label.1", _¶
"day" & Trim(Str((j - 1) + ((i - 1) * 7))), True)¶
With lbl¶
.Width = 17¶
.Height = 11.25¶
.Left = (j - 1) * .Width¶
.Top = 16 + (i - 1) * (.Height + 3)¶
.Caption = i & j¶
.FontSize = 8¶
.TextAlign = 2¶
End With¶
'Set the Controls object's day control as¶
'the one that has been created above¶
Set objDays.DayCell = lbl¶
'Put it into array control¶
Set dayArray(UBound(dayArray)) = objDays¶
Next j¶
Next i¶
'Add month names into the drop-down box¶
For i = 1 To 12¶
.cmbMonth.AddItem MonthName(i)¶
Next i¶
'Spinbutton limits¶
With .spnYear¶
.Max = 2099¶
.Min = 1980¶
End With¶
End With¶
End Sub¶
' * * * * *¶
Public Sub ChangeDay(DayCell As MSForms.Label)¶
Cmb
Search JabSto ::




Custom Search