[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need a timer on VB6

Posted on 2007-09-29
9
Medium Priority
?
201 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

0
Comment
Question by:newbieweb
  • 5
  • 4
9 Comments
 
LVL 11

Accepted Solution

by:
AkisC earned 2000 total points
ID: 19984337
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
 
LVL 11

Expert Comment

by:AkisC
ID: 19984344
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
 

Author Comment

by:newbieweb
ID: 19984434
I'm pretty new to VB.

Do I define Timer1 somewhere?

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

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 11

Expert Comment

by:AkisC
ID: 19984440
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
 
LVL 11

Expert Comment

by:AkisC
ID: 19984453
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
 

Author Comment

by:newbieweb
ID: 19984587
How do I switch to the form layout window?
0
 

Author Comment

by:newbieweb
ID: 19984618
I got it.  Thanks.
0
 

Author Comment

by:newbieweb
ID: 19984640
The Load() function is not getting called.

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

Author Comment

by:newbieweb
ID: 19985195
It works just like Visual Studio C#.

I double clicked the Form and it got created.

Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question