1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| Imports System.Runtime.InteropServices<AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Enum Or AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Interface Or AttributeTargets.Delegate,
Inherited:=True)>
<ComVisibleAttribute(True)>
Public NotInheritable Class Chron
Public Event Orange()
Public Event Rouge()
Public Event Vert()
Private D As Date, _Mode As Integer = 1
<ComVisible(True)>
Public WriteOnly Property Mode As Integer
Set(ByVal Value As Integer)
_Mode = Value
For c As Integer = 1 To 3
Controls("PictureBox" + c.ToString).Visible = False
Next
Try
Catch ex As Exception
_Mode = 1
End Try
GestionChrono()
End Set
End Property
<ComVisible(True)>
Public ReadOnly Property Temps As String
Get
Temps = Label1.Text
End Get
End Property
Private Sub Chron_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Stop()
Timer1.Interval = 5
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Controls("PictureBox" + _Mode.ToString).Visible = False
Select Case _Mode
Case 1 : _Mode = 2
Case 2 : _Mode = 3
Case 3 : _Mode = 1
Case Else : _Mode = 1
End Select
GestionChrono()
End Sub
Private Sub GestionChrono()
Controls("PictureBox" + _Mode.ToString).Visible = True
Select Case _Mode
Case 1 : Timer1.Stop() : RaiseEvent Rouge()
Case 2 : Label1.Text = "00:00:00,000" : RaiseEvent Orange()
Case 3 : D = Date.Now : Timer1.Start() : RaiseEvent Vert()
'Case 3 : D = DateTime.Parse("1/2/2018 00:00:00") : Timer1.Start()
End Select
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label1.Text = (Date.Now - D).ToString()
End Sub
Private Sub Chron_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Width = 373 : Height = 250
End Sub
End Class |
Partager