Questions on timer class and progressbar
Hi everybody
Below is a section of basic codes on how to use the timer class. May i know is there anyway i can implement a progressbar to indicate the 1 second interval for the timer class ? Thank you very much.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRx.Click
Timer1.Interval = 1000
Timer1.Enabled = True
'Do something if they respond ???
'If they respond in time turn off the timer
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MessageBox.Show("Times Up!", "Timer")
End Sub
Re: Questions on timer class and progressbar
Something like this...
VB Code:
Private iKounter As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRx.Click
Progressbar1.Max = 10
Progressbar1.Value = 0
Timer1.Interval = 1000
Timer1.Enabled = True
iKounter = 0
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
iKounter = iKounter + 1
Progressbar1.Value = Progressbar1.Value + 1
If iKounter = 10 Then
Timer1.Enabled = False
MessageBox.Show("Your 10 seconds are up!", "Timer")
End If
End Sub