Confused about paint, refresh, focus for form...

I have a VB program that reads some large text files and processes the data in them; it can take several minutes to run. Form "frmProgress" contains the guts of the code, and is displayed while the processing is going on. (The processing code is executed from its load event.) It has some informative information displayed (using label controls), and it also has a progress bar that is updated while the code runs. My problem is this: if I open another app and its window covers my "Progress..." form, when I try to go back to my "Progress... " form, the only thing on it is the progress bar ... presumably because this bar gets refreshed every time I read & process a line from a file. Why doesn't all the other stuff "repaint"? If I do a form refresh at the same time that I do the progress bar refresh, the form looks too jumpy ... isn't there something that is supposed to automatically repaint my window when its covered/uncovered? Or has focus and then loses focus? This must be a really simple thing, but I just can't figure it out ... even after paging through multiple manuals that I have. I guess I just don't know what I'm supposed to be looking for! Help!
alicia1234Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
Place a DoEvents statement in the loop so that your form can repaint.

Do While....

    'Some more code...
    DoEvents

Loop
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alicia1234Author Commented:
How often should I "DoEvents" ? Does it cause the program to run more slowly?
0
alicia1234Author Commented:
OK ... that seemed to do the trick. And doesn't seem to slow down my program. Thanks.
0
Erick37Commented:
Just once in the loop, and it will not affect performance too much because it will not do anything unless there is an event to process.

Be aware however, that while your loop is running DoEvents will allow events such as Command button click events to run.  Be sure to disable any buttons or other controls whose events you do not want to run while the loop is running.

e.g.

Command1.Enabled = False
Do While....

    'Some more code...    
    'Update Progressbar
    DoEvents

Loop
Command1.Enabled = True
0
alicia1234Author Commented:
There aren't any buttons on the form, so I'm covered. Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.