Dim mil As Byte, sec As Byte, min As Byte, ore As Byte, az As Byte, cron As Long
Private Sub avv_Click()
If az = 1 Then
Timer1.Enabled = True
avv.Caption = "Pausa"
az = 2
ElseIf az = 2 Then
Timer1.Enabled = False
avv.Caption = "Avvia"
az = 1
End If
End Sub
Private Sub Form_Load()
az = 1
Call azzera
End Sub
Private Sub Form_Unload(Cancel As Integer)
MsgBox App.Title & " è stato realizzato Giuseppe Cazzato" & Chr(13) & "Per info: giuseppec87@libero.it", vbInformation, App.Title
Unload Me
End
End Sub
Private Sub res_Click()
Timer1.Enabled = False
az = 1
avv.Caption = "Avvia"
Call azzera
End Sub
Sub azzera()
mil = 0
sec = 0
min = 0
ore = 0
cron = 0
Me.Caption = App.Title & " " & App.Major & "." & App.Minor
mil_t.Caption = mil
sec_t.Caption = sec
min_t.Caption = min
ore_t.Caption = ore
Call Controlla
End Sub
Sub Controlla()
'Controllo millisecondi
If mil_t.Caption = "0" Then mil_t.Caption = "00"
If mil_t.Caption = "1" Then mil_t.Caption = "01"
If mil_t.Caption = "2" Then mil_t.Caption = "02"
If mil_t.Caption = "3" Then mil_t.Caption = "03"
If mil_t.Caption = "4" Then mil_t.Caption = "04"
If mil_t.Caption = "5" Then mil_t.Caption = "05"
If mil_t.Caption = "6" Then mil_t.Caption = "06"
If mil_t.Caption = "7" Then mil_t.Caption = "07"
If mil_t.Caption = "8" Then mil_t.Caption = "08"
If mil_t.Caption = "9" Then mil_t.Caption = "09"
'Controllo secondi
If sec_t.Caption = "0" Then sec_t.Caption = "00"
If sec_t.Caption = "1" Then sec_t.Caption = "01"
If sec_t.Caption = "2" Then sec_t.Caption = "02"
If sec_t.Caption = "3" Then sec_t.Caption = "03"
If sec_t.Caption = "4" Then sec_t.Caption = "04"
If sec_t.Caption = "5" Then sec_t.Caption = "05"
If sec_t.Caption = "6" Then sec_t.Caption = "06"
If sec_t.Caption = "7" Then sec_t.Caption = "07"
If sec_t.Caption = "8" Then sec_t.Caption = "08"
If sec_t.Caption = "9" Then sec_t.Caption = "09"
'Controllo minuti
If min_t.Caption = "0" Then min_t.Caption = "00"
If min_t.Caption = "1" Then min_t.Caption = "01"
If min_t.Caption = "2" Then min_t.Caption = "02"
If min_t.Caption = "3" Then min_t.Caption = "03"
If min_t.Caption = "4" Then min_t.Caption = "04"
If min_t.Caption = "5" Then min_t.Caption = "05"
If min_t.Caption = "6" Then min_t.Caption = "06"
If min_t.Caption = "7" Then min_t.Caption = "07"
If min_t.Caption = "8" Then min_t.Caption = "08"
If min_t.Caption = "9" Then min_t.Caption = "09"
'Controllo ore
If ore_t.Caption = "0" Then ore_t.Caption = "00"
If ore_t.Caption = "1" Then ore_t.Caption = "01"
If ore_t.Caption = "2" Then ore_t.Caption = "02"
If ore_t.Caption = "3" Then ore_t.Caption = "03"
If ore_t.Caption = "4" Then ore_t.Caption = "04"
If ore_t.Caption = "5" Then ore_t.Caption = "05"
If ore_t.Caption = "6" Then ore_t.Caption = "06"
If ore_t.Caption = "7" Then ore_t.Caption = "07"
If ore_t.Caption = "8" Then ore_t.Caption = "08"
If ore_t.Caption = "9" Then ore_t.Caption = "09"
'Controllo finito
End Sub
Private Sub Timer1_Timer()
Call Cronometro
Call Controlla
End Sub
Sub Cronometro()
'inizio millisecondi
mil = mil + 1
If mil = 100 Then
sec = sec + 1
mil = 0
mil_t.Caption = mil
sec_t.Caption = sec
'inizio secondi
If sec = 60 Then
min = min + 1
sec = 0
sec_t.Caption = sec
min_t.Caption = min
'inizio minuti
If min = 60 Then
ore = ore + 1
min = 0
min_t.Caption = min
ore_t.Caption = ore
'inizio ore
If ore = 24 Then
ore = 0
ore_t.Caption = ore
'inizio cron
Dim vol As String, gio As String
cron = cron + 1
vol = " volte"
gio = " giorni"
If cron = 1 Then
vol = " volta"
gio = " giorno"
End If
Me.Caption = App.Title & " " & App.Major & "." & App.Minor & " ( Cronometro azzerato " & cron & vol & ", cioé son passati " & cron & gio & " )"
'fine cron
End If
'fine ore
Else
min_t.Caption = min
End If
'fine minuti
Else
sec_t.Caption = sec
End If
'fine secondi
Else
mil_t.Caption = mil
End If
'fine millisecondi
End Sub