Question numericUpDown look-a-like to set time:confused:

conan1989

Member
Joined
Jul 1, 2008
Messages
14
Programming Experience
1-3
ok so for ****s and giggles, i'm writing a windows scheduled tasks clone, and need to be able to set a time to kick-off $BLAH. if you look in "Date and Time Properties" (double click the clock)

gerr.png


i want of of them.. how do i do that?:confused:
 
partly figured it out

There's a component called SMart FieldPackEditor that does this.. Check it out?

that wasn't what i was after. i firgured out how to do a part of it:
dateTimePicker.Format = Time

but dateTimePicker.Value still contains the Date, when i just what the time.

any ideas people?
 
errrr yay?

that wasn't what i was after. i firgured out how to do a part of it:
dateTimePicker.Format = Time

but dateTimePicker.Value still contains the Date, when i just what the time.

any ideas people?

yay i've answere my own questions, don't i feel stupid lol

BLAH = dateTimePicker2.Value.ToLongTimeString
 
that wasn't what i was after. i firgured out how to do a part of it:
dateTimePicker.Format = Time

but dateTimePicker.Value still contains the Date, when i just what the time.

any ideas people?


Times always contain a date. It's a consequence of their being stored as a floating point number of days since some epoch.

You cannot remove the "date" portion of a date time any more than you can remove the 0 from 0.5

Just disregard the date, and use the time part. Given that you didnt bother to tell us how you wanted to use the time, we cant really advise, but suppose you want to know if the current time is after a time value chosen in a date picker:

VB.NET:
Dim time as TimeSpan = DateTimePicker1.Value - DateTimePicker1.Value.Date
if(DateTime.Now > (DateTime.Now.Date + time))
  MessageBox.Show("The current time is after the time entered in the DTP")
 
Back
Top