| | |
Help Using Visual Basic Timer
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2006
Posts: 1
Reputation:
Solved Threads: 0
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!
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:
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.
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)
dim CTime as string CTime = format(time, "h:mm:ss") if CTime = "22:25:00" then msgbox "it's 10:25pm" 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. ![]() |
Similar Threads
- Visual Basic Timer/Clock/Countdown. (Visual Basic 4 / 5 / 6)
- Playing .Wav/MIDI files in a Visual Basic Program (Visual Basic 4 / 5 / 6)
- Creating an OS in visual basic 6.0 (Visual Basic 4 / 5 / 6)
- The Move.....Visual Basic 6, Visual Basic .NET ? (VB.NET)
- Encrypting a Visual Basic application (Visual Basic 4 / 5 / 6)
- passing arrays in visual basic (Visual Basic 4 / 5 / 6)
- Visual Basic.net (VB.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: DataGrid - Column help needed
- Next Thread: Setting a range
Views: 7899 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






