Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show elapsed time

Status
Not open for further replies.

vinodi

Programmer
May 23, 2003
41
0
0
IN
Dear All,

In my application, I want to show the elapsed time for completion of a process that a particular form handles. To be more specific my application written in VB 6.0 generates reports in Excel. I am tracking the progress of report creation by using a progress bar on the form, from where I am issuing the command for generating the report. Once the report is generated,I display a message box stating that the Excel spreadsheet has been created at a specified location. I would also like to show the time taken to generate such a report on the form.

Something like this:
StartTime: 09/09/2005 12:00:00
End Time: 09/09/2005 12:03:05
Elapsed Time: 09/09/2005 00:03:05

Any hints/directions/solutions from the guys/gals present in the MVP box or members not present in the MVP box. Your help will be highly appreciated.

Regards,
Vinodi

~~The only place where SUCCESS comes before WORK is in the dictionary~~
 
Save the time when you start the process and when it completes as two seperate variables and then use a DateDiff to work out the differnce between the two. You can then display all three on the form.

Hope this helps.

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Vinodi,

You can also use the api GetTickCount.
Code:
  Dim lngStart
  Dim lngEnd
  Dim lngElapsed

  lngStart = GetTickCount           ' Start time

  ' Do things here (functions etc.)

  lngEnd = GetTickCount             ' End time

  lngElapsed = lngEnd - lngStart    ' Elapsed time

Just another alternative.

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Take a look at this:

Code:
Private Sub Command1_Click()
  
  TimeStart = Timer
  
  Dim i As Integer
  For i = 0 To 100000
    DoEvents    [COLOR=green]' just looping[/color]
  Next
  
  MsgBox Timer - TimeStart
  
End Sub
 
Oh, Oh.... I see it. StrongM, can I answer?

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
[smile]

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top