Results 1 to 3 of 3

Thread: [RESOLVED] Timed Code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Resolved [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.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Re: Timed Code

    Perfect! Great shout. Thank you!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width