Results 1 to 9 of 9

Thread: Progress Bar

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    262

    Progress Bar

    Anyone have a good example of how to use a progress bar to show the status of a For Loop?

  2. #2
    Banned
    Join Date
    May 2006
    Posts
    161

    Re: Progress Bar

    Huh?

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim iCount As UInteger
    3.         iCount = 32600
    4.  
    5.         Me.ProgressBar1.Maximum = iCount
    6.  
    7.         For i As Integer = 0 To iCount - 1
    8.             Me.ProgressBar1.Value += 1
    9.         Next
    10.  
    11.     End Sub

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

    Re: Progress Bar

    Quote Originally Posted by JAKSupport
    Huh?

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim iCount As UInteger
    3.         iCount = 32600
    4.  
    5.         Me.ProgressBar1.Maximum = iCount
    6.  
    7.         For i As Integer = 0 To iCount - 1
    8.             Me.ProgressBar1.Value += 1
    9.         Next
    10.  
    11.     End Sub
    Any reason why you used a UInteger versus a regular Integer?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    262

    Re: Progress Bar

    so where exactly does this progressbar showup? whats a good x y position to set it to?

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

    Re: Progress Bar

    that really depends on your GUI...

    You didn't state what you are trying to do, you just asked how to make a progress bar show a loops status

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    262

    Re: Progress Bar

    well i added the code and it appears nothing at all happens..

    VB Code:
    1. Dim progressbar As New ProgressBar
    2.  
    3.         progressbar.Maximum = tmpInt
    4.         progressbar.Value = 0
    5.  
    6.         For x = 0 To tmpInt
    7.             locid = dgCustomers.Item(0, x).Value
    8.             If locid = Nothing Then
    9.                 Exit For
    10.             Else
    11.                 result = calc.VerifyCustomer(locid)
    12.                 If result = False Then
    13.                     company = dgCustomers.Item(1, x).Value
    14.                     If company = "" Or company = Nothing Then
    15.                         company = "Uknown"
    16.                     End If
    17.                     contact = dgCustomers.Item(2, x).Value & dgCustomers.Item(3, 1).Value
    18.                     If contact = "" Or contact = Nothing Then
    19.                         contact = "Uknown"
    20.                     End If
    21.                     If Not dgCustomers.Item(4, x).Value.ToString.Length > 0 Then
    22.                         phone = "Unknown"
    23.                     Else
    24.                         phone = dgCustomers.Item(4, x).Value
    25.                     End If
    26.  
    27.                     calc.InsertCustomer(locid, company, phone, contact)
    28.                 End If
    29.             End If
    30.             progressbar.Value += 1
    31.         Next

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

    Re: Progress Bar

    Don't declare the progress bar in your code, add it to your form using the toolbox.

    You could add it in code, but you would have to add several other lines of code where adding it from the toolbox will handle adding all that code for you.

  8. #8
    Banned
    Join Date
    May 2006
    Posts
    161

    Re: Progress Bar

    Quote Originally Posted by kleinma
    Any reason why you used a UInteger versus a regular Integer?
    Heh ..well it is unsigned, you never want the maximum to be less than 0 .
    Otherwise no reason..you could used int .

  9. #9

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