MoDjo
Jun 1st, 2001, 04:51 PM
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.
Rob Brown
Jun 2nd, 2001, 05:31 AM
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.