This class implements routines for creating and manipulating the date time control from Internet Explorer's common control library.
|(Declarations)||Declarations||Declarations and private variables for the CDateTimePicker class.|
|DateTime||Property||Get the date time value of the date time picker control.|
|DisplayTime||Property||Determine whether time or date is being displayed. This is exclusive of date. There is no way to show both date and time in the same control.|
|Format||Property||Set the display format of the DateTime control.|
|Height||Property||Get the height of the DateTime control.|
|hWnd||Property||Get the handle of the DateTime control (only valid if the Create function has been called).|
|hWndParent||Property||Get the handle to the parent window (only valid if the Create function has been called).|
|Left||Property||Get the left position of the DateTime control relative to the parent window.|
|ShowCalendar||Property||Determine whether to show a dropdown calendar or up/down arrows for the control.|
|Top||Property||Get the top position of the DateTime control, relative to the parent window.|
|Width||Property||Get the width of the DateTime control.|
|Class_Terminate||Terminate||Clean up the window.|
|Create||Method||Create the DateTime picker control. This procedure should only be called after the hWndParent, Left, Top, Width, and Height properties are set.|
|Destroy||Method||Destroy the window that we created. It is not necessary to call this procedure. The Terminate event of this class destroys the window.|
|UpdatePosition||Method||Updates the controls position to the left, top, width, and height properties. This is useful if you want to change the size or position of the control after it has been created. The position is determined by the Left, Top, Width, and Height properties.|
' Example of CDateTimePicker ' ' To try this example, do the following: ' 1. Create a new form ' 2. Add a command button 'cmdTest' ' 3. Paste all the code from this example to the new form's module. ' 4. Run the form ' module-level variables for the three example controls Private mDatePicker As CDateTimePicker Private mTimePicker As CDateTimePicker Private mCalendar As CDateTimePicker Private Sub Form_Load() ' Ensure that form is created Me.Refresh ' Instantiate the three example controls Set mDatePicker = New CDateTimePicker Set mTimePicker = New CDateTimePicker Set mCalendar = New CDateTimePicker ' Set properties prior to creating the controls With mDatePicker .Left = 20 .Top = 20 .Height = 22 .Width = 100 .hWndParent = Me.hWnd .Create End With With mTimePicker .Left = 20 .Top = 44 .Height = 22 .Width = 100 .hWndParent = Me.hWnd .DisplayTime = True .Create End With With mCalendar .Left = 20 .Top = 66 .Height = 22 .Width = 100 .hWndParent = Me.hWnd .ShowCalendar = True .Create End With cmdTest.Move 300, 1350, 1500, 330 End Sub Private Sub cmdTest_Click() ' Test which date and time values were selected: MsgBox "The selected date is: " & Format$(mDatePicker.DateTime, "Short Date") MsgBox "The selected time is: " & Format$(mTimePicker.DateTime, "Short Time") MsgBox "The selected calendar date is: " & Format$(mCalendar.DateTime, "mmmm d, yyyy") End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP