?
Solved

Running timer events and loops simultaneously

Posted on 2003-02-24
5
Medium Priority
?
157 Views
Last Modified: 2010-04-07
Hi guys
I'm doing an assignment for my college course at the moment and I'm having trouble with timer events.

Basically I have a timer event to turn on an animation until a variable equals a certain value.
I want a progress bar to increment in relation to the value of this variable at the same time.
I also want a label to display the current variable value as it changes

My problem is that the progress bar and label value wait until the "do until" loop is finished to display their values and then they just jump straight up to the their current value, i.e. they don't display their increments in real time. I've tried rearranging the code in various ways but it seems that the timer event always takes full control and does not process any other code until it has finished. My programming skills are fairly basic. Any help you can give me would be greatly appreciated.

Thank you
Dave
0
Comment
Question by:davemckenna
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:Sweat
ID: 8012614
Dave,

Add a DoEvent inside your loop so the CPU has time to process other operations and that should smooth things out.

Sweat

0
 
LVL 1

Expert Comment

by:Bandy
ID: 8013625
If that doesn't work, You may also want to put a

PB1.Refresh  'Where PB1 is the name of your Progress Bar

and a

frm.Refresh  'Where frm is the name of the form containing the progress bar

just before the DoEvents
0
 

Author Comment

by:davemckenna
ID: 8032556
Hi guys,
Thanks for the help. I've managed to resolve the problem by taking the code out of a timer event all together and using a sleep command to increment the variable and the progress bar slowly. However the progress bar does not increment gradually, it jumps from e.g. 0 to 10 to 50 to 60 to 100. This happens while the variable increments gradually. The variable is tied to the progress bar. Is there a way to smooth this out?

Thanks again
Dave
0
 
LVL 2

Accepted Solution

by:
Sweat earned 200 total points
ID: 8034813
Dave,

The Sleep function halts *all* processing on your application, it literally puts it to sleep.  Any screen refresh or update only occur when the Sleep function stops and you give some control back to Windows.

I'll go back to suggesting you put a DoEvent inside your loop.  Do whatever you need to do, especially update the Progress Bar value, and then put the DoEvent inside the loop.  I've used that method and my progress bar advancing is smooth and sync's with the variables as I expect.


Sweat

0
 

Author Comment

by:davemckenna
ID: 8056885
Cheers mate, it worked a treat.

Now, on to that calendar control......:-(


Regards,
Dave
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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 While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

621 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