StopWatch Timer Addition

mr_e_landis

Registered User.
Local time
Today, 05:56
Joined
Feb 16, 2005
Messages
28
Well,

I'm trying to be all fancy and capture time on a form via start stop buttons. I understand fully how to use the timer functionality and it works great... My problem is adding the time.

I've got a text box CadTime and I want it to be 00:00 by default.
When I press my button bStartCadTime the timer starts.
This is where the problem is...
I need to add 1 second to my CadTime text box.
This would update my CadTime text box to 00:01, 00:02, 00:03, etc...
when I use Datediff Dateadd Timeserial a time of 00:00 gets kicked to 12:01 AM when I try to add 1 second...

Is there a way to start at 0 seconds then ad 1 second increments and at the same time having the hour minute format? I could do this by parsing the text box and manually adding but thats kinda silly...

Code:
Private Sub Form_Timer()
    Dim icad, imesh, icast
    If Me.CadTime.ForeColor = vbRed Then
        [U][B]Me.CadTime = Me.CadTime + 1 second <<<example only![/B][/U]
    End If
End Sub

Thank you,
:o
 
Ok so basically I'm stupid... One of my buddies found this MS link and it explains everything...

http://support.microsoft.com/kb/233275

Code:
   Dim Hours As String
   Dim Minutes As String
   Dim Seconds As String
   Dim MilliSec As String
   Dim Msg As String
   Dim ElapsedMilliSec As Long

   ElapsedMilliSec = (GetTickCount() - StartTickCount) + _
      TotalElapsedMilliSec

   Hours = Format((ElapsedMilliSec \ 3600000), "00")
   Minutes = Format((ElapsedMilliSec \ 60000) Mod 60, "00")
   Seconds = Format((ElapsedMilliSec \ 1000) Mod 60, "00")
   MilliSec = Format((ElapsedMilliSec Mod 1000) \ 10, "00")

   Me!ElapsedTime = Hours & ":" & Minutes & ":" & Seconds & ":" _
      & MilliSec
:D
 

Users who are viewing this thread

Back
Top Bottom