|
-
Jun 1st, 2001, 03:51 PM
#1
Thread Starter
New Member
Real Time Clock
Hi there... how can i get real time clock function for my counter program, i want counter in my program still run even i reset my computer, thx a lot.
-
Jun 2nd, 2001, 04:31 AM
#2
Lively Member
Why don't you take a reference to the current time when you want to start your counter using Now or Time, put it in the registry, also set a registry value telling you that you have already recorded your start time.
Then use DateDiff in a timer event to calculate the time elapsed since you started counting ie:
Option Explicit
Dim lngCounter As Long
Dim datStartTime As Date
Private Sub Form_Load
If GetSetting("MyApp", "General", "StartTimeRecorded", "No") = "No" Then
SaveSetting "MyApp", "General", "StartTime" CStr(Now)
datStartTime = Now
SaveSetting "MyApp", "General", "StartTimeRecorded", "Yes"
Else
datStartTime = CDate(GetSetting("MyApp", "General", "StartTime", CStr(Now)))
End If
Private Sub Timer1_Timer
lngCounter = DateDiff("s", lngCounter, Now)
End Sub
Hope this is of help.
Best regards,
Rob Brown.
Last edited by Rob Brown; Jun 2nd, 2001 at 04:34 AM.
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
|