PDA

Click to See Complete Forum and Search --> : datetime picker bug?


Gore
May 2nd, 2002, 09:14 AM
I have a little form with a datetimepicker(dtp1) control and a button. The form has the following code(only):

Dim tmp As Date

Private Sub dtp1_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtp1.Validated
tmp = Me.dtp1.Value
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(tmp.ToShortDateString)
End Sub

If you type a new date in the picker (5/2/2002 to 3/1/2002) and leave the cursor at the 1 (don't enter the 2002 part) and tab out, you would expect that when you press the button, tmp would give you 3/1/2002, however it gives out 3/2/2002!

I have noticed that this does not have when you pick the date from the drop down. I think it has something to do with the tabbing out of the control without moving from the section of the date you just typed (changing the day -or month- and then pressing tab instead of moving to the year section)

Any ideas on how I can fix this??