Article ID: 189991
Article Last Modified on 1/9/2003
APPLIES TO
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
This article was previously published under Q189991
SYMPTOMS
When you try to programmatically set the Month property of a DateTimePicker
control, you receive the following error message:
"Run-time error '380': Invalid property value"
If you use the drop-down Calendar to change the Month for the same date, it
works correctly.
CAUSE
When you change the Month property through the DateTimePicker control's
Calendar interface, it handles adjusting the Day property to create a valid
date. But if you assign a value to the Month property in code and this
creates an invalid date, you receive the appropriate error message.
RESOLUTION
Check to ensure that the combination of the control's current Day and Year,
along with the Month you wish to assign, combine to create a valid date.
Another approach you can take is to use the DateAdd function to change the
value of the Month property of the DateTimePicker control by adding or
subtracting the appropriate number of months. Just like the control's
graphic interface, the DateAdd function will automatically adjust for
differences in the number of days in the various months.
STATUS
This behavior is by design.
Additional query words: kbDSupport kbDSD kbVBp kbVBp600 kbCtrl
Keywords: kbprb KB189991