Im trying to read from the comm port 2 every 10 seconds or whenever i want and i want to use the timer to do it, i have all the code to read from the port i just dont know how to integrate it with the timer.
add a timer to your form, set it to be enabled (if you want it to start doing it as soon as the program starts)
interval is set in miliseconds, so 1000 = 1 seconds
and in the timer code, you type in the code you want it to do every time the interval is hit
you can start/stop the timer using TimerName.Enabled = True/False
Karl
kb244@kb244.com
Public Sub init()
Timer1.Interval = 10000 '10 seconds
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
'as long as timer1 is enabled, your program jumps here
'every 10 seconds or whatever you set the interval to.
DoEvents 'safety valve.
For i = 1 To 1000
For j = 1 To 1000
Next j
Next i
'after executing the above code, your program will jump
'here again after 10 seconds.
End Sub
You may have to disable the timer once your code within the timer1_timer() sub starts executing and re-enable it upon completion. Ten seconds isn't very long depending upon what your code is doing.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.