Setting Calendar Control Day, Month, Year using VBA

jbotts

Registered User.
Local time
Today, 00:35
Joined
Jun 8, 2009
Messages
22
I am trying to write VBA code to set the displayed date of a Calendar Control 11.0. When I write the code, the Calendar Control shows up in the intellisense, but Day, Month, and Year properties do not show up. I would like to programatically set the displayed date of the Calendar Control.

Dim myDate = 3/1/2010
myCalendar.Day = Day(myDate)
myCalendar.Month = Month(myDate)
myCalnedar.Year = Year(myDate)

The above code does not work, but there is no error message.

Any help appreciated.
 
You set the calendar value to the date not to parts of a date. You also declare your myDate variable as a DATE type.
Code:
Dim myDate As Date
myDate = #3/1/2010#
myCalendar.value = myDate
 
vbInet:
The code you suggested does change the Canlendar Control value property, but when the code is placed in the form's Load event code, it does not change the dates displayed in the form. Any suggestions as to how to change the displayed date in the Calendar Control?
 
Is your myDate variable set dynamically or is it a static date, like today's date for example?

Also, just to say don't use the hash (#) characters, surround your date with double-quotes instead ("").
myDate = "1/1/2010"
 

Users who are viewing this thread

Back
Top Bottom