PC Review


Reply
Thread Tools Rate Thread

DateTimePicker

 
 
sarndt
Guest
Posts: n/a
 
      13th Dec 2009
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
 
Reply With Quote
 
 
 
 
Nigel
Guest
Posts: n/a
 
      13th Dec 2009
I wonder if you are re-triggering the change event when your function
changes the DTPicker values? Turn off the events before and turn them on
again after the update.

HTH

--

Regards,
Nigel
(E-Mail Removed)



"sarndt" <(E-Mail Removed)> wrote in message
news:30370A26-DE8F-4CA0-AE9D-(E-Mail Removed)...
>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


 
Reply With Quote
 
sarndt
Guest
Posts: n/a
 
      13th Dec 2009
I tried to putting an Application.EnableEvents = False and an
Applicatoin.EnableEvents = True before and after the code in the Change event
but that didn't make any difference. It almost acts as if its a timing
issue. Because if I click on the updown button within 5 or 10 of the hour
change (for example 4:05 and decreasing to 3:xx, the hour changes. But if I
continue holding down the updown button and want the minutes go down to where
the hour should change to 2:xx, the hour doesn't change, and the minutes
value continues to loop.

"Nigel" wrote:

> I wonder if you are re-triggering the change event when your function
> changes the DTPicker values? Turn off the events before and turn them on
> again after the update.
>
> HTH
>
> --
>
> Regards,
> Nigel
> (E-Mail Removed)
>
>
>
> "sarndt" <(E-Mail Removed)> wrote in message
> news:30370A26-DE8F-4CA0-AE9D-(E-Mail Removed)...
> >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

>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
datetimepicker enrico via DotNetMonster.com Microsoft VB .NET 0 12th Mar 2008 05:45 AM
DateTimePicker help please =?Utf-8?B?VG9tIFJhaGF2?= Microsoft Dot NET 0 14th Feb 2005 12:29 PM
DateTimePicker =?Utf-8?B?UmF0?= Microsoft Dot NET 1 19th Mar 2004 12:53 PM
Datetimepicker =?Utf-8?B?QXZuaQ==?= Microsoft Dot NET 5 26th Jan 2004 02:12 PM
DateTimePicker Gary Miller Microsoft C# .NET 0 14th Sep 2003 04:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:59 AM.