PDA

View Full Version : Showing Progress in a Label



WillyTheFish
10-18-2008, 01:36 PM
Hello everyone,

I'm trying to write a very basic procedure for a progress bar.
The only problem I'm facing is that the order of events gets messed up :S

for example.

Call test1
Call progress(25)
Call test2
Call progress(50)
Call test3
Call progress(75)
Call test4



Public Sub progress(By Val ProVal as integer)

Label1.Caption = ProVal & "%"


I kinda looks like this, just a little more "complex". The problem is, that before the Label1.Caption even shows 25% on my UserForm, the "test4"-procedure as already started and finished :S
So it just goes straight to 75%.... how do i get it to "update" the Label1.Caption before calling other procedures? :dunno

Thanks alot!

Demosthine
10-18-2008, 01:46 PM
Good Afternoon.

Inside of your Progress sub-routine, you'll add a line of code immediately following your .Caption statement.


Public Sub progress(By Val ProVal As Integer)

Label1.Caption = ProVal & "%"
DoEvents
' Or
' UserForm.Repaint
End Sub


This basically forces Excel to repaint the Windows and it updates all of the controls before continueing on. I'd recommend DoEvents vs Repaint.

Scott

WillyTheFish
10-18-2008, 02:00 PM
ahhh... thank you so much :D