Solved

Easy Progress Bar Question

Posted on 2001-08-23
6
293 Views
Last Modified: 2012-05-04
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!
0
Comment
Question by:alicelknight
6 Comments
 
LVL 4

Accepted Solution

by:
PBuck earned 50 total points
Comment Utility
I would suggest and say not to use the ProgressBar1.Refresh - I don't think that is necessary when you are setting up the progress bar.  But why it is moving off the screen ... I don't see any code here that would move it.

Are you using MDI child forms?  For testing, why not set the Top, Left params.  Such as;

ProgressBar1.left = 200
ProgressBar1.top = 200
ProgressBar1.min = 0
ProgressBar1.max = ctr

*note .. if you are using form refreshes because you are not see movement - make sure your form autoredraw is set to true (then you may not need the refresh statements).

Hope this helps!
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
Hi aliceknight,

Donno actualy on your question, but

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

regards.
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
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.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:alicelknight
Comment Utility
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.
0
 

Author Comment

by:alicelknight
Comment Utility
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!
0
 
LVL 4

Expert Comment

by:PBuck
Comment Utility
Excellent@!  Glad things got working for you - I always disliked some of the 'actions' from using MDI child forms  :-)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now