Virtual Developer Workshop: Containerized Development with Docker

This code demonstrates how to create your own professional calendar control in VB5/6 - completely customizable with many different styles.


	This is a VB5 project, which will run under Windows 9x.
	No other than basic VB-controls are used.

	Something about making your own controls.
	None. I made the code myself and everybody is free
	to use it.






Download Zipped Project Files (10k)


  • Thanks ( and some code )

    Posted by nacnudsco on 02/02/2006 12:51am

    Thanks dude. Most wonderful. I added the following code.
    ' Procedure : GetSelectedDays
    ' DateTime  : 01/02/2006 16:50
    ' Author    : nacnud
    ' Purpose   : Just get a compressed list of the selected days
    Public Function GetSelectedDays() As Long()
        Dim lngCounter As Long
        Dim selDays() As Long
        For lngCounter = 0 To M_LNG_MAXCONTROL
            If (CellTpe(OffsetCell + lngCounter) = Selected) Then
                '# If we have an uninitilised array
                If (Not selDays) = True Then
                    ReDim Preserve selDays(0)
                    '# Otherwise, dim on the current size of it.
                    ReDim Preserve selDays(UBound(selDays) + 1)
                End If
                selDays(UBound(selDays)) = lngCounter
            End If
        Next lngCounter
        GetSelectedDays = selDays
    End Function

  • Select All and Deselect All for Calendar cells (code in comment)

    Posted by CrimsonGhost on 11/03/2005 10:58pm

    'Add these to your stCalendar.ctl
      Public Sub DeselectAll()
        Dim I As Integer
        For I = LBound(CellTpe) To UBound(CellTpe)
          If CellTpe(I) = Selected Then
            CellTpe(I) = Normal
          End If
        Next I
      End Sub
      Public Sub SelectAll()
        Dim I As Integer
        For I = LBound(CellTpe) To UBound(CellTpe)
          If CellTpe(I) = Normal Then
            CellTpe(I) = Selected
          End If
        Next I
      End Sub
    'In your frmDemoM simply use stCalendar1.SelectAll or stCalendar1.DeselectAll to call your subroutines.  Any non-date cell is ignored.

  • Make the demo US compliant (code changes in this comment)

    Posted by CrimsonGhost on 11/03/2005 09:59pm

    'In order to make this demo US calendar 
    'compliant you need to change some code.  
    'Here are the alterations.  NOTE: This 
    'mod is only for frmDemoM, but it should 
    'give you enough to go on.
    'In the various subroutines of frmDemoM 
    'find any line that says "lblDate.Caption
    '=..." and replace it with the following.
    'There should be four lines replaced in all.
    'This swaps the dd/mm/yyyy display at the 
    'top of the demo to read mm/dd/yyyy instead.
      lblDate.Caption = Format(stCalendar1.cMonth) & "/" & Format(stCalendar1.cDay) & "/" & Format(stCalendar1.cYear)
    'In the Form_Load() subroutine look for the 
    '"For I =..." loop and replace the AddItem 
    'line with the following.  It fixes the 
    'drop-down box to display the months correctly.
    'Otherwise if you run it on a US computer
    'it says January 12 times.
      cmbMonth.AddItem Format(CDate(I & "/1" & "/2005"), "mmmm")
    'Go into the stCalendar user control and the 
    'GetHeaderText() subroutine.  Replace the 
    'line under Case English with the following.  
    'This makes the day of the week row start 
    'with Sunday instead of Monday.
      CellTxt(cl) = Left(Choose(cl + 1, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"), ViewHeaderChar)
    'Lastly, under the CalcCalendar() subroutine 
    'replace line with vbMonday to this one.
    'It will realign the calendar to Sunday as the 
    'first day.
      FirstDayWD = Weekday(FirstDay, vbSunday)
    'That's it!  You should have a US compliant frmDemoM now.

  • DblClick sample as requested (code in comment)

    Posted by CrimsonGhost on 11/03/2005 09:38pm

    'Add these items to stCalendar.ctl to enable DblClick on the control:
    'Under the variable declarations add:
      'Stores MouseMove pointer coordinates
      Dim XX, YY as Integer
    'Next add a subroutine for UserControl_MouseMove as follows:
      Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        XX = X
        YY = Y
      End Sub
    'Finally, add a UserControl_DblClick subroutine.
      Private Sub UserControl_DblClick()
         Dim cl As Integer
         'Determine what cell was clicked on
         cl = (YY \ szY) * 7 + XX \ szX
         'The day number double-clicked is stored in the m_cDay variable by the MouseDown subroutine
         'Determine cell type and react accordingly
         Select Case CellTpe(cl)
           Case Header: 'add code here for trapping click on day of the week header
           Case Normal: MsgBox m_cDay & " is unselected." 'display date number in a msgbox
           Case EmptyC: 'clicked on a blank cell
           Case Selected: MsgBox m_cDay & " is selected."
         End Select
      End Sub

  • stCalendarCtl - Very useful but missing one thing

    Posted by ljwheeler on 07/14/2005 09:31pm

    Let me first thank you for making such a useful control available to those of us who find the Microsoft Calendar Control to be absolutely inadequate.
    Secondly, I would like to make a request for one additional event. That event would be named DayDblClicked. Would there be any chance of implementing such an event into your control?
    Again, thank you.
    Many regards,

  • Nice control, is there a help file or read me?

    Posted by travisreems on 05/24/2004 10:19am

    Nice control, is there a help file or read me?

  • Really useful !

    Posted by Legacy on 09/17/2003 07:00am

    Originally posted by: Humberto

    We were having problems with Mscal (the calendar control from Micro$oft) and the stcalendar save us ! It's really useful and flexible.. Even being an example to beginners, I must agree with one who said that it's useful for beginners and advanced users !
    And it's very simple to use !

    Great job !
    Thanks for saving our time !!! :)

    - Humberto -


    Posted by Legacy on 05/15/2003 07:00am

    Originally posted by: McJuke

    fantastic code - thank you!!

  • An Owner Drawn Calendar Control VB5/6 - Stefaan Casier

    Posted by Legacy on 01/03/2003 08:00am

    Originally posted by: Jose Pinto

    Sr. Cassier

    He visto algunos de sus trabajos, y debo confesarle que me
    han gustado mucho, al punto que este Calendario junto con el del Reloj, los utilizo para mis proyectos de uso personal
    en mi casa y con mis amigos. Y siento un gran orgullo al comentarles que son de un amigo alem�n.

    Deseo felicitarlo sinceramente, sus trabajos son muy confiables y de buen sentido est�tico.

    Deseo conocer m�s trabajos suyos, ya que estos aportan a mi pobre conocimiento de VB.



  • Great idea!

    Posted by Legacy on 10/09/2002 07:00am

    Originally posted by: Wrenashe


  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date