Results 1 to 2 of 2

Thread: calculating time

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 1999
    Posts
    34
    Hi, in my program i want to get the current time as soon as
    the program starts to run a batch process and again when it
    finishes running the batch process.

    that part is no problem

    what i can't seem to do is calculate how long the process
    took using the two stored times.

    how do you do this?

    thanks in advance

    MICK

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    How long of a time interval are you expecting ?

    You can use DateDiff to return the elapsed seconds.

    Code:
    Private Sub Command1_Click()
        Dim startTime As Date
        Dim finishTime As Date
        Dim elapsed As Long
        Dim x As Long
        startTime = Now
        For x = 1 To 100000000
            'Do whatever
        Next x
        finishTime = Now
        elapsed = DateDiff("s", startTime, finishTime)
        MsgBox startTime & vbCrLf & finishTime & vbCrLf & elapsed & " seconds passed"
    End Sub
    If you need something more accurate, use the GetTickCount API to get the milliseconds that have passed.

    Look here http://forums.vb-world.net/showthrea...threadid=39963 for a few other ideas.

    [Edited by jbart on 11-27-2000 at 09:11 AM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width