BUG: DateTimePicker's CustomFormat May Be Ignored

ID: Q187233


The information in this article applies to:
  • Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0


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. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.


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:

Q186424 : INFO: DateTimePicker CustomFormat Is Case-Sensitive

Additional query words: kbDSupport kbDSD kbCtrl kbUsage kbCommon kbVBp600 kbCtrl

Keywords : kbGrpVB
Version :
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: January 5, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.