Results 1 to 2 of 2

Thread: Real Time Clock

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Posts
    1

    Question 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.

  2. #2
    Lively Member
    Join Date
    May 2000
    Location
    Antrim
    Posts
    80
    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
  •  



Click Here to Expand Forum to Full Width