?
Solved

Running timer events and loops simultaneously

Posted on 2003-02-24
5
Medium Priority
?
154 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
[X]
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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

765 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