|
-
May 23rd, 2019, 07:58 AM
#6
Re: How To set timer in VB6
 Originally Posted by dglienna
Best to use a ONE SECOND (or so) timer, and count the CLICKS
It counts UP for a minute...
Code:
Option Explicit
' Add a Timer control to your project. It will be Timer1
' It looks like a stop watch in the IDE.
Dim OldTime As Date
Dim newTime As Date
Dim diff As Date
Private Sub Form_Load()
OldTime = Time
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static x As Long
Static zz$, ss$
x = x + 1
newTime = Time
diff = DateDiff("s", OldTime, newTime)
Form1.Caption = (diff \ 3600) & ":" & Format((diff \ 60 Mod 60), "00") & ":" & _
Format((diff - ((diff \ 60) * 60)), "00")
' Debug.Print (diff \ 3600) & ":" & Format((diff \ 60 Mod 60), "00") & ":" & _
Format((diff - ((diff \ 60) * 60)), "00")
If newTime = DateAdd("s", 360, OldTime) Then ' Add 360 seconds
Timer1.Enabled = False
' You time is UP! Do something!
Beep
End If
End Sub
Note to self: Reinstall VB6... Knew I forgot something...
Hi, can you help me to modify your this code to get the timing information in Milliseconds as well please?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|