![]() |
UserForm - Stop updating the caption after I click on.
Hi,
I display a userform with a progress bar (from 0% to 100%). The progress bar is displayed correctly until I click on the form. When this happens, the box and the percentage freeze (not responding). The macro continu to run correctly but it doesn't update the percentage thereafter. Is there something I can add to the macro below to update the caption or the userform? Thank you! Alex Sub ProgBar(ProgressLevel As Variant, ProgLabel As String) DoEvents With UserForm3 If IsNumeric(ProgressLevel) Then .Caption = fPercent(CStr(Round(ProgressLevel, 0))) .LabelPROGBAR.Width = (UserForm3.Width - 0 *ProgressLevel/100 .LabelPROGBAR.BackColor = RGB(0, 255 / 3, 255) Else .Caption = ProgressLevel End If .TextBoxPROGBAR.text = ProgLabel .Repaint End With End Sub -- Alex St-Pierre |
UserForm - Stop updating the caption after I click on.
Your code progress bar seems to work OK for me, I can't recreate the problem
of the label not redrawing. Don't think you need both DoEvents and .Repaint. Doevents allows a smoother redraw but might have some negative consequences if user activates a control that starts something else. Simply setting a global boolean to exit control events while work is going on might be enough. Regards, Peter T "Alex St-Pierre" wrote in message ... Hi, I display a userform with a progress bar (from 0% to 100%). The progress bar is displayed correctly until I click on the form. When this happens, the box and the percentage freeze (not responding). The macro continu to run correctly but it doesn't update the percentage thereafter. Is there something I can add to the macro below to update the caption or the userform? Thank you! Alex Sub ProgBar(ProgressLevel As Variant, ProgLabel As String) DoEvents With UserForm3 If IsNumeric(ProgressLevel) Then .Caption = fPercent(CStr(Round(ProgressLevel, 0))) .LabelPROGBAR.Width = (UserForm3.Width - 0 *ProgressLevel/100 .LabelPROGBAR.BackColor = RGB(0, 255 / 3, 255) Else .Caption = ProgressLevel End If .TextBoxPROGBAR.text = ProgLabel .Repaint End With End Sub -- Alex St-Pierre |
UserForm - Stop updating the caption after I click on.
Hi Peter,
When the user click on CreateReport, it open a form with a progress bar and a cancel button. I use DoEvents to catch the Click on the Cancel button of the UserForm3. I'm wondering if there's an other way to catch the Cancel click by setting a global boolean to exit control? This should avoid the non responding message of the DoEvents. I used .Repaint to refresh the display of a listview. So, in this case, it is not necessary (I'll remove it). Thank you! Alex Form1: Private Sub CreateReport_Click() UserForm1.Hide Load UserForm3 UserForm3.Show End Sub Form3: Private Sub CommandButtonCancel_Click() Call EndReport(True) End Sub Private Sub Userform_Activate() Call CreateWordReport("NotUsed") Call EndReport End Sub -- Alex St-Pierre "Peter T" wrote: Your code progress bar seems to work OK for me, I can't recreate the problem of the label not redrawing. Don't think you need both DoEvents and .Repaint. Doevents allows a smoother redraw but might have some negative consequences if user activates a control that starts something else. Simply setting a global boolean to exit control events while work is going on might be enough. Regards, Peter T "Alex St-Pierre" wrote in message ... Hi, I display a userform with a progress bar (from 0% to 100%). The progress bar is displayed correctly until I click on the form. When this happens, the box and the percentage freeze (not responding). The macro continu to run correctly but it doesn't update the percentage thereafter. Is there something I can add to the macro below to update the caption or the userform? Thank you! Alex Sub ProgBar(ProgressLevel As Variant, ProgLabel As String) DoEvents With UserForm3 If IsNumeric(ProgressLevel) Then .Caption = fPercent(CStr(Round(ProgressLevel, 0))) .LabelPROGBAR.Width = (UserForm3.Width - 0 *ProgressLevel/100 .LabelPROGBAR.BackColor = RGB(0, 255 / 3, 255) Else .Caption = ProgressLevel End If .TextBoxPROGBAR.text = ProgLabel .Repaint End With End Sub -- Alex St-Pierre |
All times are GMT +1. The time now is 01:48 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com