How can I perform an action every second?

Posted on 2003-03-09
Medium Priority
Last Modified: 2010-05-01
I want a program to calculate a random number every second.
Coding the random number I can do,but getting it to produce one every second has me stumpped.
I know it must have some thing to do with the timer but I can't figure it out.
Can someone help me?

thanks in advance
Question by:ives31
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

DocM earned 200 total points
ID: 8098893
'Put a timer control on the form
Private Sub Form_Load()
 Timer1.Interval = 1000
 Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
 Call MyAction
End Sub

Sub MyAction()
 'Your code
End Sub

Expert Comment

ID: 8098895
place a timer on the form, then set its 'interval' property to 1000, which is 1000 milliseconds which is 1 second. then double click on the timer. the code window will pop up, where you type the code you want to happen every second. to stop the timer, just set its Enabled property to False

Author Comment

ID: 8099042
thanks for your help.
I did actually figure it out just after I posted the question :)

Thanks again for your help :)

Expert Comment

ID: 8900443
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
LVL 49

Expert Comment

ID: 9074531
Moderator, my recommended disposition is:

    Accept DocM's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

752 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