LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default DateTimePicker

I have datetimepicker controls on my worksheet. They are set to display time
in hh:mm tt format. I've coded the change events to add/subtract an hour
based on going from hh:59 to hh:60 and hh:00 to hh:59. This works fine if
you click on the updown arrow in the spinner portion of the control. But it
doesn't work if you hold down the mouse key. What happens in this case is
the minutes go/up down, but the hour doesn't change. My code so far is as
follows:

Public Time As Date

Private Sub DTPicker1_SD_GotFocus()

Time = DTPicker1_SD.Value

End Sub

Private Sub DTPicker1_SD_Change()

DTPicker1_SD.Value = Validate_Time(DTPicker1_SD)
Time = DTPicker1_SD.Value

End Sub

Private Function Validate_Time(ByRef DTPickerField As DTPicker)

Dim Time_Mn As Integer

Time_Mn = Minute(Time)

If Time_Mn = 0 And DTPickerField.Minute = 59 Then
If DTPickerField.Hour = 0 Then
DTPickerField.Hour = 11
Else
DTPickerField.Hour = DTPickerField.Hour - 1
End If
End If
If Time_Mn = 59 And DTPickerField.Minute = 0 Then
DTPickerField.Hour = DTPickerField.Hour + 1
End If
Set Validate_Time = DTPickerField

End Function

Thanks in advance for any assistance
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DateTimePicker control problem Jac Tremblay[_4_] Excel Programming 0 December 13th 08 02:54 AM
DateTimePicker crazybass2 Excel Programming 3 January 11th 06 11:34 PM


All times are GMT +1. The time now is 03:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"