Public
Class Form1
Private
hora As Integer
= 0
Private minuto As Integer = 0
Private segundo As Integer = 0
Private milisegundo As
Integer = 0
Sub mostrarTiempo()
Label2.Text
= hora.ToString.PadLeft(2, "0")
& ":"
Label2.Text &=
minuto.ToString.PadLeft(2, "0")
& ":"
Label2.Text &=
segundo.ToString.PadLeft(2, "0")
& ":"
Label2.Text &=
milisegundo.ToString.PadLeft(1, "0")
Label1.Refresh()
End Sub
Private Sub Button1_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button1.Click
Dim TimeInicio As DateTime = "00:15:00"
Label1.Text = TimeInicio.ToString("mm:ss")
Timer1.Interval
= 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Timer1.Tick
Try
Dim
NovaData As DateTime
= DateTime.Parse("00:"
& Label1.Text)
Label1.Text =
NovaData.AddSeconds(-1).ToString("mm:ss")
If
Label1.Text = "00:00" Then
Timer1.Enabled = False
End
If
Catch
ex As Exception
End Try
End Sub
Private Sub Button2_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button2.Click
Timer2.Enabled = True
End Sub
Private Sub Timer2_Tick(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Timer2.Tick
milisegundo += 1
If milisegundo = 9 Then
milisegundo
= 0
segundo += 1
If segundo = 59 Then
segundo = 0
minuto += 1
If
minuto = 59 Then
minuto = 0
hora += 1
End
If
End
If
End If
mostrarTiempo()
End Sub
Private Sub Button3_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button3.Click
Timer2.Enabled = False
End Sub
Private Sub Button4_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button4.Click
hora = 0
minuto = 0
segundo = 0
milisegundo = 0
mostrarTiempo()
End Sub
End Class
0 comentários:
Postar um comentário