Anyone have a good example of how to use a progress bar to show the status of a For Loop?
Printable View
Anyone have a good example of how to use a progress bar to show the status of a For Loop?
Huh?
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim iCount As UInteger iCount = 32600 Me.ProgressBar1.Maximum = iCount For i As Integer = 0 To iCount - 1 Me.ProgressBar1.Value += 1 Next End Sub
Any reason why you used a UInteger versus a regular Integer?Quote:
Originally Posted by JAKSupport
so where exactly does this progressbar showup? whats a good x y position to set it to?
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
well i added the code and it appears nothing at all happens..
VB Code:
Dim progressbar As New ProgressBar progressbar.Maximum = tmpInt progressbar.Value = 0 For x = 0 To tmpInt locid = dgCustomers.Item(0, x).Value If locid = Nothing Then Exit For Else result = calc.VerifyCustomer(locid) If result = False Then company = dgCustomers.Item(1, x).Value If company = "" Or company = Nothing Then company = "Uknown" End If contact = dgCustomers.Item(2, x).Value & dgCustomers.Item(3, 1).Value If contact = "" Or contact = Nothing Then contact = "Uknown" End If If Not dgCustomers.Item(4, x).Value.ToString.Length > 0 Then phone = "Unknown" Else phone = dgCustomers.Item(4, x).Value End If calc.InsertCustomer(locid, company, phone, contact) End If End If progressbar.Value += 1 Next
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.
Heh :)..well it is unsigned, you never want the maximum to be less than 0 :).Quote:
Originally Posted by kleinma
Otherwise no reason..you could used int :).