Microsoft KB Archive/187233

= BUG: DateTimePicker's CustomFormat May Be Ignored =

Article ID: 187233

Article Last Modified on 5/13/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q187233



SYMPTOMS
You have a DataTimePicker control's CustomFormat property set, but when you set the Format property to dtpCustom, the CustomFormat is not used.



RESOLUTION
When you set a DateTimePicker's Format property to dtpCustom, you must follow this by assigning the CustomFormat property, even if it already contains a valid format string. This assignment to CustomFormat may be a new string value or it may be assigned to itself.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 In a new Standard EXE project. Form1 is created by default. From the Projects menu, select Components, check "Microsoft Windows Common Controls-2 6.0," and click OK. Add two CommandButtons and a DTPicker control to Form1. Enter a custom format into the DTPicker control's CustomFormat property. For this example, use 'Today is' MMM d, yyy.  Add the following code to the Form's Module: Private Sub Command1_Click DTPicker1.Format = dtpCustom End Sub

Private Sub Command2_Click DTPicker1.Format = dtpCustom DTPicker1.CustomFormat = DTPicker1.CustomFormat End Sub

 Run the Project and Click Command1. Note that the CustomFormat is not used and the date is displayed as a short date. Click Command2 and note that the CustomFormat is used and the date is displayed in the form: Today is May 5, 1998.</li></ol>

<div class="references_section">