Help Using Visual Basic Timer

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2006
Posts: 1
Reputation: EricDLeh is an unknown quantity at this point 
Solved Threads: 0
EricDLeh EricDLeh is offline Offline
Newbie Poster

Help Using Visual Basic Timer

 
0
  #1
Jan 28th, 2006
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!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Help Using Visual Basic Timer

 
0
  #2
Jan 28th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 7899 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC