How to Create a Stopwatch Timer in Visual FoxProLast reviewed: November 14, 1995Article ID: Q139390 |
The information in this article applies to:
SUMMARYIt 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 INFORMATIONThe 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 reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |