|
-
November 6th, 1998, 06:48 PM
#1
Time elapsed
Anyone know how I can get the time elapsed of a application? I wanna know how long something took to run. I tried:
Dim time1, time2, TimeElapsed
time1 = time$
'Application runs here
time2 = time$
TimeElapsed = (time2-time1)
Any idea why its not working, and now I can get it to work? thanks 
-
November 7th, 1998, 07:57 AM
#2
Re: Time elapsed
Use the GetTickCount API ... the declarations you need can be found in the API Viewer. It can be used like this.
Dim time1%,time2%,elapsed%
time1 = GetTickCount()
'whatever process you are timing
time2 = GetTickCount()
elasped = time2-time1
'elapsed will be the number of milliseconds that have elapsed
'GetTickCount rolls over every 49 days of continuous system operation so if 'time1 is greater than time2, you have to make the necessary adjustment
Gordito
-
November 27th, 1998, 12:36 PM
#3
Re: Time elapsed
Alex:
You have several issues with this code:
1. Always type your variables (Dim time1 As Date), otherwise they are variants (really slow).
2. Putting a $ returns a string, your untyped time1 will now hold the string.
3. You then try subtracting strings
Try this:
Dim x As Date
Dim y As Date
x = Now
'' App runs here
y = Now
Call MsgBox(DateDiff("s", x, y) & " seconds have passed.", vbInformation)
Tested in VB5.
-Jim
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
|