Restricting time entries

pachjo

Well-known member
Joined
Dec 12, 2006
Messages
370
Programming Experience
10+
I have two datetimepicker controls as follows:

dtpStartDate = long date

dtpStartTime = custom "hh:mm"

I cannot seem to restrict the hour component of the dtpStartTime values to be between 07:00am - 18:00pm

I have tried using the as New datetime(y,m,d, 7, 0, 0) to no avail.

Any pointers please?

Thanks
 
Always the way!

Spend hours trying to solve it, then drop a post and then solve it!!!

I used the startdate.value as a base value to prime the time control.

But....how do I force the time control to display in 24hr format?

Ta
 
Spend hours trying to solve it, then drop a post and then solve it!!!
So you validated the Hour value in Validating event?
I used the startdate.value as a base value to prime the time control
Why not use only one TP control? While displaying only time (or custom date-time) user can still dropdown the date picker.
how do I force the time control to display in 24hr format?
custom "HH:mm"
 
my original attempt was:

New datetime(Today.year,Today.month,Today.day, 7, 0, 0) to no avail.

But then I tried assigning the startdate dtp to a datetime variable d and did this

New datetime(d.year,d.month,d.day, 7, 0, 0)

and this worked, restricting the lowest value to 7.

I did the same and using 18 for the endtime range.

The HH:mm worked a treat in forcing the control into 24hr mode!

Cheers ears :)
 
You can also set minimum and maximum dates with the MinimumDateTime and MaximumDateTime properties. Or was that perhaps what you did?
Use Date data type instead of the DateTime structure, they are really the same, but using data types is better.
 
I have it working a treat now so will probably leave it be.

However does the MinimumDateTime and MaximumDateTime require a date as well as a time?
 
The Date data type always contains both date and time parts.
 
Back
Top