Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've got a lengthy routine that can take a few seconds to run and I
thought it would be nice to include a progress bar. The routine is largely just a loop, so tracking progress is easy. So I put it all together and the form with the progress bar is shown (modeless), but it doesn't update. I can break the code (Esc key) and all is working as it should - counter values, percent complete label , progress bar width are all correct and update visually when I break the code. And I can step through the code and all works well. I've even added a Sleep command to slow things down, with no luck. Can the code be executing too fast for the form to be visually updated?? I thought it might be something in my longer routine, so I ripped out the progress bar part and tried it in a new workbook. Same results. Code for that is below. Can anyone tell why I don't see my form update? Basics are that I am updating the parameters of labels on a userform: 1) lblFore is the "bar" and a width of 350 is 100% complete 2) lblPct shows the percent complete value Thanks, John Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub junk() UserForm1.Show vbModeless For i = 1 To 1000 iWidth = i / 1000 * 350 UserForm1.lblFore.Width = iWidth ipct = i / 1000 * 100 UserForm1.lblPct = ipct Sleep 100 Next i UserForm1.Hide End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As shown, your progress code will complete almost instantaneously.
The label width should depend on the actual progress of your lengthy routine (LR). So if your LR is 10% complete then the value of i passed to the "junk" sub should be 100. Then, each time the userform is updated (the label width changes) you need to tell Excel to redraw the form. Do that with: UserForm1.Repaint '-- Jim Cone Portland, Oregon USA . http://www.mediafire.com/PrimitiveSoftware . (Permutations Add-in: with option to highlight valid words) "John" wrote in message ... I've got a lengthy routine that can take a few seconds to run and I thought it would be nice to include a progress bar. The routine is largely just a loop, so tracking progress is easy. So I put it all together and the form with the progress bar is shown (modeless), but it doesn't update. I can break the code (Esc key) and all is working as it should - counter values, percent complete label , progress bar width are all correct and update visually when I break the code. And I can step through the code and all works well. I've even added a Sleep command to slow things down, with no luck. Can the code be executing too fast for the form to be visually updated?? I thought it might be something in my longer routine, so I ripped out the progress bar part and tried it in a new workbook. Same results. Code for that is below. Can anyone tell why I don't see my form update? Basics are that I am updating the parameters of labels on a userform: 1) lblFore is the "bar" and a width of 350 is 100% complete 2) lblPct shows the percent complete value Thanks, John Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub junk() UserForm1.Show vbModeless For i = 1 To 1000 iWidth = i / 1000 * 350 UserForm1.lblFore.Width = iWidth ipct = i / 1000 * 100 UserForm1.lblPct = ipct Sleep 100 Next i UserForm1.Hide End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calling Form Routine from Another Workbook | Excel Programming | |||
Update Links Stopping Workbook_Open Routine | Excel Programming | |||
ChangeLinks routine stopped by Update Values dialog | Excel Programming | |||
Fast Fourier Transform routine in Tools add-in menu | Excel Worksheet Functions | |||
Help Fast! Can I add chart to user form in Excel VBA | Excel Programming |