Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer function in VB

Status
Not open for further replies.

Electromechanical30

Industrial
Sep 15, 2004
45
I'm am in the process of creating an HMI using Basic.

I do have it up and running! [thumbsup2]

I'd like to add a function that will update the PLC every second or so.
OnTimer... I need to write to a PLC register automatically. I have never really employed timers in my code before (fairly new to this type of programming).

Can anyone provide a simple code example. I should be able to pick it up from there.

Thanks!!
 
Replies continue below

Recommended for you

Add a Timer control to your form. Set its Interval property to 1000 (set in millisecs). When you want the timer to run, set its Enabled property to True

The Timer event will then fire every 1 sec (subject to other PC processes) until you set Enabled to False:
[tt]
Private Sub Timer1_Timer()
' Your code goes here
End Sub
[/tt]

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor