Option Explicit
Dim SecondCount As Long, RecPath As String
Private Sub Form_Load()
RecPath = App.Path & "\TimeRecord.txt"
If Dir(RecPath) = "" Then
SecondCount = 0
Else
Open RecPath For Input As #1
Input #1, SecondCount
Close #1
End If
Timer1.Interval = 1000
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open RecPath For Output As #1
Print #1, SecondCount
Close #1
End Sub
Private Sub Timer1_Timer()
Dim h%, m%, s%, sh$, sm$, ss$
h = SecondCount \ 3600
sh = IIf(h = 0, "", h & "小时")
m = SecondCount \ 60
sm = IIf(m = 0 And h = 0, "", m & "分钟")
s = SecondCount Mod 60
ss = IIf(s = 0, "", s & "秒")
Label1.Caption = sh & sm & ss
SecondCount = SecondCount + 1
End Sub