Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Routine too fast for Form to Update?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Routine too fast for Form to Update?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Form Routine from Another Workbook Denis[_4_] Excel Programming 1 October 30th 08 04:45 PM
Update Links Stopping Workbook_Open Routine michael.beckinsale Excel Programming 0 August 20th 07 10:30 AM
ChangeLinks routine stopped by Update Values dialog [email protected] Excel Programming 1 September 14th 06 04:42 AM
Fast Fourier Transform routine in Tools add-in menu Tutorguy Excel Worksheet Functions 1 March 23rd 06 04:49 PM
Help Fast! Can I add chart to user form in Excel VBA Brian Barbre Excel Programming 2 November 30th 03 05:46 PM


All times are GMT +1. The time now is 07:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"