-
[RESOLVED] Timed Code
Hi All
Looking for the user to be able to enter a time into a textbox in the format:
17:00:00
And when the programme is running, and the time reaches 17:00:00, it will trigger some code.
Here's some code I tried and didn't work.
Code:
Dim theTime As DateTime
theTime = CDate(tbTime.Text)
If theTime.Hour = Now.Hour And theTime.Minute = Now.Minute Then
Label1.Text = "it worked"
End If
It said that conversion from string to date is not valid.
Help is appreciated.
-
Re: Timed Code
Use a DateTimePicker (.Format = Time) instead. It ensures that you always get valid input and solves the problem of times which straddle midnight by allowing the picking of as date as well.
-
Re: Timed Code
Perfect! Great shout. Thank you! :)