Link to home
Start Free TrialLog in
Avatar of alicelknight
alicelknight

asked on

Easy Progress Bar Question

Hi All!
Having problems refreshing the progress bar on a separate form.  How can I make the form appear then disappear with the pb in the proper place and not appear to be off the form?
Here is part of my code...
Private Sub cmdSendEMail_Click()
    Dim iRow As Integer
    Dim ctr As Integer
    Dim i As Integer
   
    On Error GoTo PROC_ERR
       
    ctr = 0
    i = 0
   
    For iRow = 0 To fgShip.Rows - 1
        If fgShip.Cell(flexcpChecked, iRow, 0) = flexChecked Then
            ctr = ctr + 1
        End If
    Next iRow
   
    If ctr = 0 Then Exit Sub
   
    frmPBEMail.Show
    'frmPBEMail.Refresh
    frmPBEMail.ProgressBar1.Value = 0
    'frmPBEMail.ProgressBar1.Refresh
    frmPBEMail.ProgressBar1.Max = ctr
    'ProgressBar1.Max = ctr
   
    i = 0
    ...................................
    ..............................

    For iRow = 0 To fgShip.Rows - 1
        If fgShip.Cell(flexcpChecked, iRow, 0) = flexChecked Then
            i = i + 1
            frmPBEMail.Label2.Caption = "Notification " & i & " of " & ctr & " Being Sent..."
            frmPBEMail.Refresh
            frmAuctionCorr.txtTo.text = Trim(fgShip.TextMatrix(iRow, 16))
            frmAuctionCorr.Get_NoteVariables (fgShip.TextMatrix(iRow, 2))
            frmAuctionCorr.cmdSend_Click
            frmPBEMail.ProgressBar1.Value = i
            frmPBEMail.Refresh
        End If
    Next iRow
   
    Unload frmAuctionCorr
    Unload frmPBEMail
   
    mbolEditing = False
   
    Exit Sub
PROC_ERR:
..................
End Sub

In frmPBEMail I have Me.Refresh in Form_Load()
Thanks!
ASKER CERTIFIED SOLUTION
Avatar of PBuck
PBuck

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ryan Chong
Hi aliceknight,

Donno actualy on your question, but

To be more effective, use DoEvents after the progressbar.value + 1 ..

regards.
Avatar of wsh2
wsh2

As ryancys said.. the DoEvents will allow frmPBEMail the opportunity to repaint the screen. To move frmPBEMail to the top of the application.. you may want to show it as Modal.
Avatar of alicelknight

ASKER

Thanks all for your help.  But why is the pb form now minimized in my tray?  I want it to show on top of the form that's currently open.
PBuck:

Thanks, it was a problem with the refreshes.  Also, it's minimized in my tray because of it being a MDI child form.  I set the borderstyle to fixed single and all seems to work fine.

Everyone:  Thanks for your help.  It was a combination of all but the mention of the MDI child form got me on the right track and not using so many refreshes.  Thanks all for your help!
Excellent@!  Glad things got working for you - I always disliked some of the 'actions' from using MDI child forms  :-)