Public Class Timer Inherits System.Windows.Forms.Form Private timerbeatSeconds As Integer = 0 Dim timerBeatMinutes As Integer = 0 Dim timerBeatHours As Integer = 0 Property TimerEnabled() As Boolean Get Return Timer1.Enabled End Get Set(ByVal Value As Boolean) Timer1.Enabled = Value End Set End Property Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick timerbeatSeconds = timerbeatSeconds + 1 If timerbeatSeconds = 60 Then timerBeatMinutes = timerBeatMinutes + 1 timerbeatSeconds = 0 End If If timerBeatMinutes = 60 Then timerBeatHours = timerBeatHours + 1 timerBeatMinutes = 0 End If lblSec.Text = timerbeatSeconds.ToString("00") lblMinutes.Text = timerBeatMinutes.ToString("00" & " : ") lblHeure.Text = timerBeatHours.ToString("00" & " : ") End Sub Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click Timer1.Start() End Sub Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click Timer1.Stop() End Sub Private Sub Timer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = False Timer1.Interval = 1000 lblSec.Text = "00" lblMinutes.Text = "00" & " : " lblHeure.Text = "00" & " : " Timer1.Start() End Sub Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click timerBeatMinutes = 0 timerbeatSeconds = 0 timerBeatHours = 0 lblSec.Text = "00" lblMinutes.Text = "00" & " : " lblHeure.Text = "00" & " : " End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question