Results 1 to 8 of 8

Thread: Progress Barsss

  1. #1

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492

    Progress Barsss

    How can I make a progress bar that works with the record set.
    For instance say I sql out 10 records...and I need each block
    of the progress bar to represent say what .10 so that I have the following

    10 records:
    .10+.10+...+.10 = 100%

    So each time I loop through a record I add an additional .10 to the progress bar. Or is there an easier way to do this...I want a progress bar because im sendign data to excel so I dont want users to close the application down if it takes long...I want them to see a progress bar of whats left.

    If anyone has examples or c ode please POST!!!!!


    Thanks Guys!

    Jon

  2. #2
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Albany, NY
    Posts
    489
    I think it is in the Microsoft Windows common
    controls 6.0 component



    VB Code:
    1. Me.ProgressBar1.Max = (Me.Fg2.Rows - 1) * (Me.Fg2.Cols - 1)
    2. Me.ProgressBar1.Min = 0
    3. Me.ProgressBar1.Value = 0
    4.  
    5. For RowIndex = 1 To (Me.Fg2.Rows - 1)
    6.     For ColIndex = 1 To (Me.Fg2.Cols - 1)
    7.         Me.Fg2.Row = RowIndex
    8.         Me.Fg2.Col = ColIndex
    9.         Me.ProgressBar1.Value = Me.ProgressBar1.Value + 1
    10.     Next
    11. Next


    For the above code just increment the
    progress bar Counter while looping
    through your data.

  3. #3

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    [QUOTE]Originally posted by jcfowl
    [B]I think it is in the Microsoft Windows common
    controls 6.0 component



    VB Code:
    1. Me.ProgressBar1.Max = (Me.Fg2.Rows - 1) * (Me.Fg2.Cols - 1)
    2. Me.ProgressBar1.Min = 0
    3. Me.ProgressBar1.Value = 0
    4.  
    5. For RowIndex = 1 To (Me.Fg2.Rows - 1)
    6.     For ColIndex = 1 To (Me.Fg2.Cols - 1)
    7.         Me.Fg2.Row = RowIndex
    8.         Me.Fg2.Col = ColIndex
    9.         Me.ProgressBar1.Value = Me.ProgressBar1.Value + 1
    10.     Next
    11. Next

    Hmm thanks for the reply...just not sure how to use this code...
    for instance say im going through a loop of records

    VB Code:
    1. while Not rs.eof
    2.      'do some work
    3.      'add a little to the progress bar
    4.      rs.movenext
    5. wend

    That is how I would be using it....

    Jon

  4. #4
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Albany, NY
    Posts
    489

    Hmm thanks for the reply...just not sure how to use this code...
    for instance say im going through a loop of records

    VB Code:
    1. while Not rs.eof
    2.      'do some work
    3.      'add a little to the progress bar
    4.      rs.movenext
    5. wend

    That is how I would be using it....

    Jon [/B]

    VB Code:
    1. Me.ProgressBar1.Max = rs.RecordCount
    2. Me.ProgressBar1.Min = 0
    3. Me.ProgressBar1.Value = 0
    4.  
    5. while Not rs.eof
    6.      'do some work
    7.      'add a little to the progress bar
    8.      rs.movenext
    9. Me.ProgressBar1.Value = Me.ProgressBar1.Value + 1
    10.  
    11. wend

  5. #5

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    I came up with it.
    Your method would increment the progress bar but not correctly. Since the number of records is unknown you would have to get a record count and use it as a denominator like so:

    ProgressBar1.Value = ProgressBar.Value + (100/rst.RecordCount)

    This way if rst has 10 records then:
    100/10=10

    10 is added per record so that the last record ensures the progress bar hits 100.

    Jon

  6. #6
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Albany, NY
    Posts
    489
    why do you want it to hit 100?
    just curious.....

  7. #7

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    The max value doesnt really matter...in fact it could be N
    where N is some positive integer less than the maximum size allowed by the progress bar. I choose 100 cause that's the default that vb assigns to the Progress Bar.

    Jon

  8. #8

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    Excuse my stupidity
    Your method is just as valid...I did not notice the line with the max assigned to the record count. That is actually a less mathematical method .

    Jon

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