Microsoft KB Archive/139390

= How to Create a Stopwatch Timer in Visual FoxPro =

Article ID: 139390

Article Last Modified on 2/10/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q139390



SUMMARY
It can be useful to track the amount of time that was spent in a Visual FoxPro application. By using the timer control in Visual FoxPro, you can create a timer to track elapsed time.



MORE INFORMATION
The following code creates a form that begins tracking the elapsed time when it is launched. It displays the total time in a WAIT WINDOW when the form is closed. PUBLIC ostopwatch

oStopWatch=CreateObject('stopwatch') ostopwatch.Visible=.T.

DEFINE CLASS stopwatch AS form AutoCenter = .T.     Top = 32 Left = 9 Height = 137 Width = 293 DoCreate = .T.     Caption = "" etime = 0 Name = "Form1"

ADD OBJECT command1 AS commandbutton WITH ; Top = 48, ; Left = 84, ; Height = 49, ; Width = 133, ; Caption = "Quit", ; Name = "Command1"

ADD OBJECT timer1 AS timer WITH ; Top = 12, ; Left = 12, ; Height = 23, ; Width = 23, ; Interval = 1000, ; Name = "Timer1"

PROCEDURE Unload WAIT WINDOW 'Elapsed Time = '+ALLTRIM(STR(ThisForm.etime))+ ; ' Seconds' ENDPROC

PROCEDURE command1.Click THISFORM.Release ENDPROC

PROCEDURE timer1.Timer THIS.Parent.etime=This.Parent.etime+1 THIS.Parent.Caption='Elapsed Time ='+ ; ALLTRIM(STR(This.Parent.etime))+' Seconds' ENDPROC

ENDDEFINE

Additional query words: VFoxWin

Keywords: kbcode KB139390

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.