Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95

View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?


"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




Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: DateTimePicker in Category Microsoft Visual Basic 6 : Controls from Total Visual SourceBook

Implement the DateTime Picker Windows common control in VB6.

This class implements routines for creating and manipulating the date time control from Internet Explorer's common control library.

Procedure List

Procedure Name



(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 Code for Using Class: DateTimePicker

' 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

  ' 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
  End With

  With mTimePicker
    .Left = 20
    .Top = 44
    .Height = 22
    .Width = 100
    .hWndParent = Me.hWnd
    .DisplayTime = True
  End With

  With mCalendar
    .Left = 20
    .Top = 66
    .Height = 22
    .Width = 100
    .hWndParent = Me.hWnd
    .ShowCalendar = True
  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

Microsoft Access Module LibraryOverview of Total Visual SourceBook

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.

Additional Resources