Type | Description | |||
X as OLE_XPOS_PIXELS | A single expression that indicates the X position in client coordinate | |||
Y as OLE_YPOS_PIXELS | A single expression that indicates the Y position in client coordinate | |||
Date | 0 or a DATE expression that indicates the date from point (X,Y) |
Use the DateFromPoint property to get the date from the cursor. if X = -1 and Y = -1, the DateFromPoint property retrieves the date from the cursor, shortly the DateFromPoint(-1,-1) returns the date from the cursor.
The following VB sample displays the date being clicked:
Private Sub Calendar1_Click() Dim d As Date With Calendar1 d = .DateFromPoint(-1, -1) If Not (d = 0) Then MsgBox "You have clicked: " & d End If End With End Sub
The following VB sample displays the date being clicked, including the associated event:
Private Sub Calendar1_Click() Dim d As Date, s As String With Calendar1.Object d = .DateFromPoint(-1, -1) If Not (d = 0) Then s = "You have clicked: " & d Dim e As EXCALENDARLibCtl.Event Set e = .Events.Item(CDate(d)) If Not e Is Nothing Then s = s + vbCrLf + "The date has associated an event" End If End If End With If (Len(s) > 0) Then MsgBox s End If End Sub
In VBA/MSAccess, you need to replace the EXCALENDARLibCtl with EXCALENDARLib, else you will be prompted for a compiler error: "Can't find project or library"
The following sample shows how to print the date over the cursor:
Private Sub Calendar1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim d As Date d = Calendar1.DateFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY) If d <> 0 Then Debug.Print FormatDateTime(d) End If End Sub