Results 1 to 5 of 5

Thread: Progress bar help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    Progress bar help

    I currently have a progress bar that increments depending on what is set in my program by a drop down box (txtDelayTimKickOver.Text), values range from 1-20. Depending on what value is selected from txtDelayTimKickOver.Text, the program bar is supposed to increment on that number. This will cause a delay in my program in second dependent on that selected value.

    My problem is that the progress bar looks like it reaches 100% when it is actually halfway done.

    How do I always make the progress reach 100% when it is supposed to based on txtDelayTimKickOver.Text?


    Code:
            For i As Integer = 1 To txtDelayTimKickOver.Text
                ProgressIndicator.Value += txtDelayTimKickOver.Text
                System.Threading.Thread.Sleep(1000)
            Next

  2. #2
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: Progress bar help

    How many times does this loop run? I only ask because I do not see where you set the initial value of ProgressIndicator.Value. Also, your are using implicit type conversions that should be avoided, i.e. instead of just using txtDelayTimKickOver.Text, use Integer.Parse(txtDelayTimKickOver.Text).

    As far as your percentage goes, your calculations are flawed. If txtDelayTimKickOver can be any value from 1 - 20, then lets assume it equals 20. Your Progress loop would execute like this:
    1 + 1 = 2
    2 + 2 = 4
    4 + 3 = 7
    7 + 4 = 11
    11 + 5 = 16
    16 + 6 = 22
    22 + 7 = 31
    etc....


    Can you elaborate a little more on what your program is actually doing?
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  3. #3
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641

    Re: Progress bar help

    Code:
    ProgressIndicator.MaxValue = Ctype(txtDelayTimKickOver.Text, Integer)
    For i As Integer = 1 To txtDelayTimKickOver.Text
                ProgressIndicator.Value += txtDelayTimKickOver.Text
                System.Threading.Thread.Sleep(1000)
            Next
    Martin J Wallace (Slaine)

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    Re: Progress bar help

    I am going to use the For loop of the progress bar as a delay. The user can set the delay anywhere from 1 -20 seconds. I would like the progress bar to show how much time has past in the desired delay.

  5. #5
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: Progress bar help

    Quote Originally Posted by Slaine
    Code:
    ProgressIndicator.MaxValue = Ctype(txtDelayTimKickOver.Text, Integer)
    For i As Integer = 1 To txtDelayTimKickOver.Text
                ProgressIndicator.Value += txtDelayTimKickOver.Text
                System.Threading.Thread.Sleep(1000)
            Next
    Your code has the same mathematical error. Use this instead:

    Code:
    ProgressIndicator.MaxValue = Ctype(txtDelayTimKickOver.Text, Integer)
    For i As Integer = 1 To Integer.Parse(txtDelayTimKickOver.Text)
                ProgressIndicator.Value = i
                System.Threading.Thread.Sleep(1000)
            Next
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

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