Need a timer on VB6

I have a function debugged and working.  Now I need to call it every 5 (or so) seconds.

Could someone please show me the code I need for this?  If will run 24/7, so please consider robustness, etc.

It's VB 6.0.


thanks,
newbieweb

newbiewebSr. Software EngineerAsked:
Who is Participating?
 
AkisCCommented:
Private Sub Form_Load()
    Me.Timer1.Enabled = True
    Me.Timer1.Interval = 5000  '5 sec'
End Sub

Private Sub Timer1_Timer()
    Call YourFunction
End Sub
0
 
AkisCCommented:
if your function takes more than 5 sec to complete then consider...

Private Sub Timer1_Timer()
    Me.Timer1.Enabled = False
    Call YourFunction
    Me.Timer1.Enabled = True
End Sub
0
 
newbiewebSr. Software EngineerAuthor Commented:
I'm pretty new to VB.

Do I define Timer1 somewhere?

I see that "Me" is known by the environment, but not Timer1.

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
AkisCCommented:
From the tool box select the timer control and then drop it on your form
The timer control is the one with a clock icon
Click on it. The cursor changes to a cross... then draw a squaere on your form. That drops the timer on your form
0
 
AkisCCommented:
If you do not see the toolbox (to your left) then click on the View menu of VB6 and from the drop down menu click toolbox. You may also hit Alt+vx sortcut for the toolbox to appear
0
 
newbiewebSr. Software EngineerAuthor Commented:
How do I switch to the form layout window?
0
 
newbiewebSr. Software EngineerAuthor Commented:
I got it.  Thanks.
0
 
newbiewebSr. Software EngineerAuthor Commented:
The Load() function is not getting called.

Do I need to do more than just create the code for it?
0
 
newbiewebSr. Software EngineerAuthor Commented:
It works just like Visual Studio C#.

I double clicked the Form and it got created.

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.