Microsoft Office Tutorials and References
In Depth Information
Using Calendar Control for Office Applications
'Selected day is not existing in newly selected month¶
'Set the last day of month¶
Me.Value = CLng(DateSerial(cVarCYear, _¶
.cmbMonth.ListIndex + 2, 0))¶
Else¶
'We can use the same day number¶
'It is in range of the next month¶
Me.Value = CLng(DateSerial(cVarCYear, _¶
.cmbMonth.ListIndex + 1, cVarCDay))¶
End If¶
'Change month view¶
Call SelectDate¶
End With¶
End Sub¶
' * * * * *¶
Private Sub cmdOK_Click()¶
'Close calendar¶
Unload Me¶
End Sub¶
' * * * * *¶
Private Sub cmdToday_Click()¶
'Set calendar value as today¶
'and repaint calendar by using selected date¶
Me.Value = Date¶
Call SelectDate¶
End Sub¶
' * * * * *¶
Private Sub spnYear_Change()¶
'This is the event that is triggered by¶
'clicking the year spin control¶
With Me¶
'Set year textbox value¶
.txtYear.Value = .spnYear.Value¶
'If the selected day is in the range of the newly¶
'selected month then there is no problem¶
'However if selected day is 31 and the next month¶
'has only 30 days then this should be handled¶
If cVarCMonth <> .cmbMonth.ListIndex + 1 Then¶
'Selected day does not exist in newly selected month¶
'Set to the last day of month¶
Me.Value = CLng(DateSerial(.spnYear.Value, _¶
.cmbMonth.ListIndex + 2, 0))¶
Else¶
'Use the same day number¶
'It is in range of the next month¶
Me.Value = CLng(DateSerial(.spnYear.Value, _¶
.cmbMonth.ListIndex + 1, cVarCDay))¶
End If¶
'Change month view¶
Call SelectDate¶
End With¶
Cmb
Search JabSto ::




Custom Search