Progress bar

GerardPosada

New member
Joined
Sep 30, 2008
Messages
2
Location
Tampa, Florida
Programming Experience
Beginner
hey im trying to make a progress bar i know it needs a timer but i dont know the proper code.. this is for my class im a total newb in VB.NET lmao

thanks for your help
 
First thing you need to know is what are you processing? General you do a progress bar based on TotalItems vs. ItemsCurrentlyProcessed.
 
For example lets process a the rows in a DataSet.

VB.NET:
pgBar.Maximum = dsData.Tables(0).Rows.Count - 1
pgBar.Minimum = 0
For RowCnt as Integer = 0 to dsData.Tables(0).Rows.Count - 1
'Process something here
pgBar.Value = RowCnt
Next

Or

VB.NET:
For RowCnt as Integer = 0 to dsData.Tables(0).Rows.Count - 1
' Process something here
pgBar.Value = Cint(100 * (RowCnt + 1) / dsData.Tables(0).Rows.Count)
Next
 
hey im trying to make a progress bar i know it needs a timer but i dont know the proper code.. this is for my class im a total newb in VB.NET lmao

thanks for your help

Here's code for my timer:
VB.NET:
   Private Const PROGRESSBAR_MIN As Integer = 1
   Private Const PROGRESSBAR_MAX As Integer = 90
VB.NET:
    Private Sub PaperTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PaperTimer.Tick
        PaperProgressBar.Visible = True
        If PaperProgressBar.Value >= PROGRESSBAR_MAX Then
            PaperProgressBar.Value = PROGRESSBAR_MIN
        Else
            PaperProgressBar.Value += 1
       End If
    End Sub


...as long as the timer is firing, the progress bar continues to count. You will have to figure out when the timer starts and stops.
 
Last edited:
Back
Top