I’ve been using the Google Calendar lately, and it’s not bad.  It reminded me of a calendar I made a few years ago, but Google did it a bit better.  So I copied Google’s color scheme and changed a few things to make mine more like the Google one.

This code is in the form of an ActiveX Control written in VB6.  Source code is provided below.

Included with the project is a class called clsEvent.  The control holds a collection of these classes in chronological order, allowing events for multiple months to be stored.  Depending on your application, you can add properties and methods to that class, and use the control to hold all of your information.  Check out the test app to see this in action.
Event Calendar

Image: Event Calendar Test Application
Event Calendar Control (28kB)

Categories: Source Code, VB

9 Responses so far.

  1. samsul says:

    Thanks for sharing the code, I use it for studying VB

  2. dimitris says:

    Thank you a lot for sharing the code… This program is very useful.. I have a problem…. I can’t convert this code to vb.net or visual basic 2005… Could you help me? Is there this code for vb.net? Thank you a lot!!!

  3. peter says:

    Hi dimitris, I haven’t converted this to .Net, a I don’t think I’d recommend it. It would be completely different, so the VB code is not much use. Check out this control: Calendar DayView. It’s not a month view, but you can show a week at a time.

  4. dimitris says:

    Thank you very much for your advice, for your link and for your direct reply!!!

  5. Dan says:

    Great control. How would one clear the calendar in order to re-populate it from a table.

  6. peter says:

    Dan, add this to the code in the .ctl file to give you a Clear method:

    Public Sub Clear()
    ' Clear Event Collection:
    Set m_EventList = New Collection
    ' Refresh display:
    AddEventsToListboxes
    End Sub

    Then you can re-populate from whatever source you have. The AddItem function creates instances of the clsEvent class to store the data you need for each event. You can even add members to this class if you need to store more data, or perform actions on it.

    If you need access to the entire event collection, add this to the control:


    Public Function Count() As Integer
    Count = m_EventList.Count
    End Function

    Public Function GetEventByIndex(idx As Integer) As clsEvent
    If idx > 0 And idx < = Count Then Set GetEventByIndex = m_EventList(idx)
    End Function

  7. Rob says:

    What about deleting a specific event without losing other events on the same day?

  8. peter says:

    Hi Rob, I think you’ve found a bug. In the RemoveItem sub, the line Exit Sub should be Exit For:


    Public Sub RemoveItem(EventClass As clsEvent)
    Dim i As Long

    For i = 1 To m_EventList.Count
    If EventClass Is m_EventList(i) Then
    m_EventList.Remove i
    Exit For
    End If
    Next i

    AddEventsToListboxes
    End Sub

    The items were being removed correctly, but not updated on the screen.

  9. Sigster says:

    Hi
    Thanks for sharing

    I am just beginer in vb6
    and I am wonder if you can show me how I read from access database into the Calendar Please

    Regards
    Sigster

Leave a Reply