Results 1 to 9 of 9

Thread: Progessbar problem

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    54

    Red face Progessbar problem

    Hi Guys

    Can anyone please give me the code to activate a progressbar when a tab PAGE loads.



    Thanks

    Nick

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Progessbar problem

    What do you mean by "activate"? You have to set the value of a ProgressBar yourself, so you can't just call a method or set a property and have it start incrementing. Every time the ProgressBar moves it's because you tell it to explicitly, by either calling PerformStep or by setting the Value property.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    54

    Re: Progessbar problem

    i know

    but how

    Ta

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Progessbar problem

    ProgressBar.Value += 1

    but what jmcilhinney was getting at, is there needs to be some REASON for using a progress bar.. most commonly a loop of some sort where you want to show progress as the loop is working

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    54

    Re: Progessbar problem

    so how would i code it to run when a tabpage loads?

    here is what i ahve so far
    VB Code:
    1. Dim ProBr As Long
    2.         ProgressBar1.Value = 0
    3.         Do While ProgressBar1.Value < ProgressBar1.Maximum
    4.             ProgressBar1.Value += 1

    what do i need to add to this code so it runs while the tabpage is loading

    TA
    Last edited by nickj; Oct 21st, 2005 at 08:08 PM.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Progessbar problem

    A ProgressBar is supposed to indicate the progress of an operation, so you have to set the Value property each time you want it to change. You don't just start it going and it increments itself. If you want it to show that an operation is 10% complete then you need to set the Value property to 10% of the Maximum value. If you then want it to show that an operation is 50% complete then you have to set the Value property to 50% of the Maximum. The ProgressBar knows nothing about your TabPage. You have to tell it what to display every step of the way.

    Anyway, you still haven't answered my question. You say "activated" and "loading" like we're supposed to know what that means. A TabPage will display almost instantaneously, so there's no need to use a Progressbar for that. I assume that you mean that you are retrieving data from a database or something like that. If that's the case, how about you say so.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    54

    Re: Progessbar problem

    ok, ok, easy tiger

    The tabpage is used to read information from an excel file. It contains a lot of labels and it can take time to load the info, there for i would like the progressbar to run until it loads. There are 8-30 tabpages that all have different info. (these tabpoages are created at run time by the user selecting the required number from a combobox)

    Also as were on the topic of progressbar’s how would I use one on say form1 while form1 loads the tasbpages as above?

    Thanks

    Nick
    (sorry for not being clear)

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Progessbar problem

    You would set the Value property or call the PerformStep or Increment method at various points in the code that loads your data. You need to decide what those points will be and you need to explicitly write the code that updates the ProgressBar. For instance, if your code performs 10 actions you would most likely set the Minimum and Value to 0, the Maximum to 10 and the Step to 1, then call PerformStep after each action. If each action is not considered an equal portion of the task however, you would more likely set the Maximum property to something like 100 and then call Increment to increase the Value to whatever percentage of the entire task had been completed after each action.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9
    Lively Member bmilano's Avatar
    Join Date
    Jan 2005
    Location
    Broad Run, VA
    Posts
    126

    Re: Progessbar problem

    In my case, the solution isn't elegant, but it works really well.

    I created a very simple form with just a progress bar on it that is shown immediately when my program starts. The form has one public method with a single argument, and that method is used to update the progress bar value to the supplied value. I found it necessary to Refresh the progress bar and the form every time the progress bar value was updated so that the updates would be shown to the user.

    At various points in the program initiation, I update the progress bar accordingly, e.g. frmFrmLoading.subSetProgressBar(65). The "various points" and associated values with those points so that the progress bar was accurate were determined via trial and error. When initialization is complete, my main form disposes of the form with the progress bar, and the main form opens.

    I use an "AppStarting" cursor on the progress bar form, and it is a FixedToolWindow.

    I have attached the form to this posting in case anyone is interested.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width