ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Form Repainting Problem (https://www.excelbanter.com/excel-programming/351447-form-repainting-problem.html)

ybazizi

Form Repainting Problem
 
I have a label on a form that I use to show the progress of a loop. It works
great except if I change the focus to a different application and then return
to excel. Doing so freezes the label where it was when I changed the focus.
Is there a to get the form to start refreshing again?

Thanks


For i = 1 To LastRow
lblStatus.Caption = i & " of " & LastRow
frmStatus.Repaint
...the rest of the loop
Next i


Tom Ogilvy

Form Repainting Problem
 
Perhaps

For i = 1 To LastRow
lblStatus.Caption = i & " of " & LastRow
frmStatus.Repaint
doevents
...the rest of the loop
Next i

--
Regards,
Tom Ogilvy


"ybazizi" wrote in message
...
I have a label on a form that I use to show the progress of a loop. It

works
great except if I change the focus to a different application and then

return
to excel. Doing so freezes the label where it was when I changed the

focus.
Is there a to get the form to start refreshing again?

Thanks


For i = 1 To LastRow
lblStatus.Caption = i & " of " & LastRow
frmStatus.Repaint
...the rest of the loop
Next i




Crowbar via OfficeKB.com

Form Repainting Problem
 
Don't know how useful this is but I found pausing the application works with
things like this, this will pause the loop for half a second that usaully is
more than enough time for the computer to refresh

Dim PauseTime, Start, Finish

For i = 1 To LastRow

PauseTime = 0.5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
Loop
Finish = Timer ' Set end time.

lblStatus.Caption = i & " of " & LastRow
frmStatus.Repaint
...the rest of the loop
Next i

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200601/1

ybazizi

Form Repainting Problem
 
The DoEvents did the trick. Thanks!

"Tom Ogilvy" wrote:

Perhaps

For i = 1 To LastRow
lblStatus.Caption = i & " of " & LastRow
frmStatus.Repaint
doevents
...the rest of the loop
Next i

--
Regards,
Tom Ogilvy


"ybazizi" wrote in message
...
I have a label on a form that I use to show the progress of a loop. It

works
great except if I change the focus to a different application and then

return
to excel. Doing so freezes the label where it was when I changed the

focus.
Is there a to get the form to start refreshing again?

Thanks


For i = 1 To LastRow
lblStatus.Caption = i & " of " & LastRow
frmStatus.Repaint
...the rest of the loop
Next i






All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com