We help IT Professionals succeed at work.

Need a timer on VB6

218 Views
Last Modified: 2010-05-18
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

Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
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
curiouswebsterSoftware Engineer

Author

Commented:
I'm pretty new to VB.

Do I define Timer1 somewhere?

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

CERTIFIED EXPERT

Commented:
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
CERTIFIED EXPERT

Commented:
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
curiouswebsterSoftware Engineer

Author

Commented:
How do I switch to the form layout window?
curiouswebsterSoftware Engineer

Author

Commented:
I got it.  Thanks.
curiouswebsterSoftware Engineer

Author

Commented:
The Load() function is not getting called.

Do I need to do more than just create the code for it?
curiouswebsterSoftware Engineer

Author

Commented:
It works just like Visual Studio C#.

I double clicked the Form and it got created.

Thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.