|
-
Apr 1st, 2000, 05:16 AM
#1
Thread Starter
New Member
Hello,
How is possible capture the start time of any program,and when it stop,the stop time.
For example:
when I open my file (to write),a timer start, when I have finish I close the file the timer stop.
I not know how I must control the open and close file event
Tank's ... is very inportant to me
-
Apr 1st, 2000, 10:48 AM
#2
Sure. Try something like this:
Code:
Private Sub Command1_Click()
Dim datStart As Date
Dim datFinish As Date
Dim strMsg As String
datStart = Now
'Open File and do your stuff here
datFinish = Now
datFinish = datFinish - datStart
strMsg = "Hours: " & Hour(datFinish) & vbCrLf
strMsg = strMsg & "Minutes: " & Minute(datFinish) & vbCrLf
strMsg = strMsg & "Seconds: " & Second(datFinish)
MsgBox strMsg
End Sub
-
Apr 1st, 2000, 10:56 AM
#3
Addicted Member
flazanel,
I'm not sure if I fully understand your question, but here goes...
If you want to capture the start time and stop time of the application you designed and compiled, then in the start up procedure (ie. Form_Load event or Sub Main) write the current time to a log file. The example below will write the start time to a log file called AppLog.txt.
Code:
Private Sub Form_Load()
Open "AppLog.txt" For Append As #1
Print #1, App.EXEName & " Started: " & Now
Close #1
'The rest of your application code would continue on from here.
End Sub
Then add similar code to the application stop event (either the menu item, command button, or form_unload event that stops the program.
Code:
Private Sub Form_Unload(Cancel As Integer)
Open "AppLog.txt" For Append As #1
Print #1, App.EXEName & " Stopped: " & Now
Close #1
Unload Me
End
End Sub
If you want to log the start and stop time of other applications that you didn't write (ie. commercial word processor, spreadsheet, database, etc) then you would have to write an app that looks at processes that start and terminate and log the times from there. This would be much more difficult. If you have Microsoft Outlook, you can use the Journal feature of this program, to monitor the start and stop times of various programs and documents. That would definitely be the easier route for this scenario.
Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|