BUG: DateTimePicker's CustomFormat May Be Ignored (187233)



The information in this article applies to:

  • Microsoft Visual Basic Learning Edition for Windows 6.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. 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.
  2. Add two CommandButtons and a DTPicker control to Form1.
  3. Enter a custom format into the DTPicker control's CustomFormat property. For this example, use 'Today is' MMM d, yyy.
  4. 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
    
    						
  5. Run the Project and Click Command1. Note that the CustomFormat is not used and the date is displayed as a short date.
  6. Click Command2 and note that the CustomFormat is used and the date is displayed in the form: Today is May 5, 1998.

REFERENCES

For additional information, please see the following article in the Microsoft Knowledge Base:

186424 : INFO: DateTimePicker CustomFormat Is Case-Sensitive


Modification Type:MajorLast Reviewed:5/13/2003
Keywords:kbbug KB187233