Progress bar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abolos
    New Member
    • Apr 2007
    • 65

    Progress bar

    Hi all,

    I have a command button that opens a form. This form takes many seconds to open. What I need is to add a progress bar to that shows how much still have to finally open the form.

    Any help?

    Thanks
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by abolos
    Hi all,

    I have a command button that opens a form. This form takes many seconds to open. What I need is to add a progress bar to that shows how much still have to finally open the form.

    Any help?

    Thanks
    Do not load many things in Form load event. Because user gets irritate, if they cannot see the form for long time

    Comment

    • hariharanmca
      Top Contributor
      • Dec 2006
      • 1977

      #3
      Originally posted by abolos
      Hi all,

      I have a command button that opens a form. This form takes many seconds to open. What I need is to add a progress bar to that shows how much still have to finally open the form.

      Any help?

      Thanks

      you can use progress bar by
      1. set minvalue =0
      2. set maxvalue=<End status Value>
      3. increase status according to the complete status of the process

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Is it the actual load of the form which takes so long, or is it some set-up that your code is doing after it loads?

        If the former, then I think you'll be out of luck.

        If the latter, it should be relatively simple to show a progress bar somewhere (on the first form, or in a pop-up dialogue) and update it periodically while you do your stuff.

        One mistake people often make (as hariharanmca pointed out) is to do too much work in the Form_Load procedure. This can slow down the time it takes to get the form on-screen, and thus the users perception of how "snappy" your application is. There are various ways you might overcome this. One simple method is simply to do a "show" at the start of the load routine, to make the form visible ASAP. It all depends, of course, on what you are doing in the load procedure.

        One important concept to keep in mind, though - the actual speed is not as important as the perceived speed. Splash screens are a good example of this. If you tell Windows to start an app, then have to wait 15 seconds, you'll be really annoyed. But if you tell Windows to start an app, wait a couple of seconds, then get a splash screen that sits there for another 10 or 15 seconds, it seems as though "something is happening", and is much less annoying.

        Comment

        • abolos
          New Member
          • Apr 2007
          • 65

          #5
          Originally posted by Killer42
          Is it the actual load of the form which takes so long, or is it some set-up that your code is doing after it loads?

          If the former, then I think you'll be out of luck.

          If the latter, it should be relatively simple to show a progress bar somewhere (on the first form, or in a pop-up dialogue) and update it periodically while you do your stuff.

          One mistake people often make (as hariharanmca pointed out) is to do too much work in the Form_Load procedure. This can slow down the time it takes to get the form on-screen, and thus the users perception of how "snappy" your application is. There are various ways you might overcome this. One simple method is simply to do a "show" at the start of the load routine, to make the form visible ASAP. It all depends, of course, on what you are doing in the load procedure.

          One important concept to keep in mind, though - the actual speed is not as important as the perceived speed. Splash screens are a good example of this. If you tell Windows to start an app, then have to wait 15 seconds, you'll be really annoyed. But if you tell Windows to start an app, wait a couple of seconds, then get a splash screen that sits there for another 10 or 15 seconds, it seems as though "something is happening", and is much less annoying.

          Thank you guys for your replies. Good ideas to put in mind for later use.

          Actually, I don't have anything in the Form_Load. What I have is a form that runs a query and this query is doing calculation. And for this time (calculation time) I want to put a progress bar just to let the user knows that the programs is doing something and didn't died.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by abolos
            Actually, I don't have anything in the Form_Load. What I have is a form that runs a query and this query is doing calculation. And for this time (calculation time) I want to put a progress bar just to let the user knows that the programs is doing something and didn't died.
            That might be a problem.

            I guess the fundamental question is, can your code do anything? What I mean is, are you simply issuing a database query, and waiting ages before control returns to your code? If so, your code can't do anything for the duration. But if your code is doing a query and then spending ages performing calculations based on it, then you just need to insert something in the code to periodically take a moment to show the user it's working.

            If it's the former case (single call, locked up until it returns) you might want to consider modifying the way you perform the calculation. I've had to do this myself when I had, for example, a large file to import (on a regular basis) to my database. The import could run for an hour or two. I wanted to be able to see something happening, and maybe click an Abort button to interrupt it. So I just had my code read the text file and insert the records, while using DoEvents to keep the interface alive, and updating a progress bar.

            Comment

            • abolos
              New Member
              • Apr 2007
              • 65

              #7
              Originally posted by Killer42
              That might be a problem.

              I guess the fundamental question is, can your code do anything? What I mean is, are you simply issuing a database query, and waiting ages before control returns to your code? If so, your code can't do anything for the duration. But if your code is doing a query and then spending ages performing calculations based on it, then you just need to insert something in the code to periodically take a moment to show the user it's working.

              If it's the former case (single call, locked up until it returns) you might want to consider modifying the way you perform the calculation. I've had to do this myself when I had, for example, a large file to import (on a regular basis) to my database. The import could run for an hour or two. I wanted to be able to see something happening, and maybe click an Abort button to interrupt it. So I just had my code read the text file and insert the records, while using DoEvents to keep the interface alive, and updating a progress bar.
              In my case the code does nothing, just runquery. I think it is difficult to put a progress bar in this form.

              Thanks again,
              abolos

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Originally posted by abolos
                In my case the code does nothing, just runquery. I think it is difficult to put a progress bar in this form.
                Yep, sure sounds that way.

                As I said, there may be ways to break down the query into separate chunks that you can run, updating a progress display in between, but that depends on what the query does.

                You might also want to consider whether there are ways to speed up the query, too. Any chance you could show us what the query does? (I mean, just post the SQL here or something.) I think optimising SQL is more of an art than a science.

                Comment

                • deaddog4201
                  New Member
                  • Jun 2007
                  • 9

                  #9
                  Couldn't you just add a timer to loop until your query is done and run the progress bar on the timer not the query that would at least give the user something to look at at and know the app is working and not just locked up

                  Comment

                  • Killer42
                    Recognized Expert Expert
                    • Oct 2006
                    • 8429

                    #10
                    Originally posted by deaddog4201
                    Couldn't you just add a timer ...
                    That might depend on the version of VB. But as far as I know, it won't work in VB6. It's worth trying, of course, but I'm pretty sure the timer won't fire until control comes back from the database query.

                    Comment

                    • Firecore
                      New Member
                      • Jul 2007
                      • 114

                      #11
                      I know for a fact that it will not work in VB6.
                      Believe me, I tried.

                      Comment

                      • JonJacobs
                        New Member
                        • Aug 2007
                        • 22

                        #12
                        Someone suggested breaking the query into smaller pieces so you could update the UI between the pieces.

                        That may be a good idea for an additional reason.

                        If the query is complex or has a lot of joins, sometimes breaking the query up into smaller pieces, carefully chosen, can actually Speed Up the process. I have experienced this many times. Might be worth looking at.

                        What database system?

                        HTH

                        Comment

                        • abolos
                          New Member
                          • Apr 2007
                          • 65

                          #13
                          Originally posted by JonJacobs
                          Someone suggested breaking the query into smaller pieces so you could update the UI between the pieces.

                          That may be a good idea for an additional reason.

                          If the query is complex or has a lot of joins, sometimes breaking the query up into smaller pieces, carefully chosen, can actually Speed Up the process. I have experienced this many times. Might be worth looking at.

                          What database system?

                          HTH

                          Thanks for your suggestions, I'll try to use the timer and see. I'm using Access 2000 in this database.

                          Comment

                          • Killer42
                            Recognized Expert Expert
                            • Oct 2006
                            • 8429

                            #14
                            Originally posted by abolos
                            Thanks for your suggestions, I'll try to use the timer and see. I'm using Access 2000 in this database.
                            Good luck. But I'll be a bit surprised if it works.

                            Comment

                            Working...