943,984 Members | Top Members by Rank

Ad:
Jan 28th, 2006
0

Help Using Visual Basic Timer

Expand Post »
I need some help using Visual basic 6.0 to read the computer's clock and use it to execute a command at a specific time of day. I am using the computers parallel port and visual basic to control a stepper motor and I need the motor to turn on at specific times of day. The program will run all the time and say for example 3 o'clock hits, visual basic will execute a command and turn on the motor. I am having some trouble finding information for this, as I am a pretty novice visual basic user. Anyone have any information and/or links for me? Thanks!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EricDLeh is offline Offline
1 posts
since Jan 2006
Jan 28th, 2006
0

Re: Help Using Visual Basic Timer

Sure,

The function is simply "Time", but it comes in a specific format. You can use the format function, to specify the format the time returns for example:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. dim CTime as string
  2. CTime = format(time, "h:mm:ss")
  3. if CTime = "22:25:00" then
  4. msgbox "it's 10:25pm"
  5. end if

If you research the format and time function, you can have it set for 24 hour time, or 12 hour time, and you can specify how many digits per part of the time. Then just compare and execute Keep in mind, however, that you would want to put this in a timer control, and set the interval to either 1 second or 100Milliseconds (I use 100ms, but every second would work just as well), the timer control's interval property works in Milliseconds, so 1 second would be 1000ms. Also, remember to disable the timer, or set a flag variable after the time hits, and the program runs the commands, otherwise, it will continue to run those commands over and over again until the time is no longer (in this case) 22:25:00. Let me know how it turns out.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: DataGrid - Column help needed
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Setting a range





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC