Monday 9 January 2012

ProgressBar with Timer Control


Insert Timer Control into the project. Its default name is Timer1.

Private Sub btnTimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimer.Click
        If btnTimer.Text = "START" Then
            Timer1.Start()
            btnTimer.Text = "STOP"
        Else
            Timer1.Stop()
            btnTimer.Text = "START"
        End If
    End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ProgressBar1.Value += 1
        If ProgressBar1.Value = ProgressBar1.Maximum Then
            Timer1.Stop()
            btnTimer.Text = "START"
        End If
    End Sub


Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        ProgressBar1.Value = 0
    End Sub


No comments:

Post a Comment