+ Reply to Thread
Results 1 to 8 of 8

VBA Timer

  1. #1
    Lisa
    Guest

    VBA Timer

    Hi All,

    I'm looking for a simple timer routine that will show the time elapsed for
    each cycle of a Do Until ...Loop instruction. (the loop can go on for many
    millions of cycles)

    I'm thinking of something like :-

    Before the *Do Until* starts t0 = current time

    For each cycle within the loop t1 = current time and
    Cells(1,1,) = t1-t0

    But how?

    Many thanks

    Lisa

    BTW I'm using XL97



  2. #2
    moon
    Guest

    Re: VBA Timer


    Private Sub YourSub()
    Dim pTime, pStart, pEnd, tTime, lTime
    'five seconds
    pTime = 5
    pStart = Timer
    Do While Timer < pStart + pTime
    DoEvents
    lTime = (pStart + pTime) - Timer
    'update label (or anything else)
    timeLabel.Caption = Round(lTime, 0)
    Loop
    pEnd = Timer
    tTime = pEnd - pStart
    End Sub




    "Lisa" <[email protected]> schreef in bericht
    news:[email protected]...
    > Hi All,
    >
    > I'm looking for a simple timer routine that will show the time elapsed for
    > each cycle of a Do Until ...Loop instruction. (the loop can go on for many
    > millions of cycles)
    >
    > I'm thinking of something like :-
    >
    > Before the *Do Until* starts t0 = current time
    >
    > For each cycle within the loop t1 = current time and
    > Cells(1,1,) = t1-t0
    >
    > But how?
    >
    > Many thanks
    >
    > Lisa
    >
    > BTW I'm using XL97
    >




  3. #3
    Jean-Yves
    Guest

    Re: VBA Timer

    Hello,
    Go in VBA heflp, time timer , see example.
    It's all there

    Regrds
    JY

    "Lisa" <[email protected]> wrote in message
    news:[email protected]...
    > Hi All,
    >
    > I'm looking for a simple timer routine that will show the time elapsed for
    > each cycle of a Do Until ...Loop instruction. (the loop can go on for many
    > millions of cycles)
    >
    > I'm thinking of something like :-
    >
    > Before the *Do Until* starts t0 = current time
    >
    > For each cycle within the loop t1 = current time and
    > Cells(1,1,) = t1-t0
    >
    > But how?
    >
    > Many thanks
    >
    > Lisa
    >
    > BTW I'm using XL97
    >




  4. #4
    moon
    Guest

    Re: VBA Timer


    Private Sub YourSub()
    Dim pTime, pStart, pEnd, tTime, lTime
    'five seconds
    pTime = 5
    pStart = Timer
    Do While Timer < pStart + pTime
    DoEvents
    lTime = (pStart + pTime) - Timer
    'update label (or anything else)
    timeLabel.Caption = Round(lTime, 0)
    Loop
    pEnd = Timer
    tTime = pEnd - pStart
    End Sub




    "Lisa" <[email protected]> schreef in bericht
    news:[email protected]...
    > Hi All,
    >
    > I'm looking for a simple timer routine that will show the time elapsed for
    > each cycle of a Do Until ...Loop instruction. (the loop can go on for many
    > millions of cycles)
    >
    > I'm thinking of something like :-
    >
    > Before the *Do Until* starts t0 = current time
    >
    > For each cycle within the loop t1 = current time and
    > Cells(1,1,) = t1-t0
    >
    > But how?
    >
    > Many thanks
    >
    > Lisa
    >
    > BTW I'm using XL97
    >




  5. #5
    Jean-Yves
    Guest

    Re: VBA Timer

    Hello,
    Go in VBA heflp, time timer , see example.
    It's all there

    Regrds
    JY

    "Lisa" <[email protected]> wrote in message
    news:[email protected]...
    > Hi All,
    >
    > I'm looking for a simple timer routine that will show the time elapsed for
    > each cycle of a Do Until ...Loop instruction. (the loop can go on for many
    > millions of cycles)
    >
    > I'm thinking of something like :-
    >
    > Before the *Do Until* starts t0 = current time
    >
    > For each cycle within the loop t1 = current time and
    > Cells(1,1,) = t1-t0
    >
    > But how?
    >
    > Many thanks
    >
    > Lisa
    >
    > BTW I'm using XL97
    >




  6. #6
    Lisa
    Guest

    Re: VBA Timer

    Thanks Moon,
    I appreciate your help but is there not a simpler way to achieve this?
    I'm sure your code will work but I understand very little of it and , as a
    newbie, I need to learn in small doses.

    Is it not possible to do it as I originally set it out?
    i.e. at start t0 = current time
    during loop t1 = current time
    during loop shove the difference between t0 & t1 into a cell on the
    worksheet

    As I said, I appreciate any help but I can't help feeling that there must be
    a simpler way.

    Best Reagrds
    Lisa


    "moon" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Private Sub YourSub()
    > Dim pTime, pStart, pEnd, tTime, lTime
    > 'five seconds
    > pTime = 5
    > pStart = Timer
    > Do While Timer < pStart + pTime
    > DoEvents
    > lTime = (pStart + pTime) - Timer
    > 'update label (or anything else)
    > timeLabel.Caption = Round(lTime, 0)
    > Loop
    > pEnd = Timer
    > tTime = pEnd - pStart
    > End Sub
    >
    >
    >
    >
    > "Lisa" <[email protected]> schreef in bericht
    > news:[email protected]...
    >> Hi All,
    >>
    >> I'm looking for a simple timer routine that will show the time elapsed
    >> for each cycle of a Do Until ...Loop instruction. (the loop can go on for
    >> many millions of cycles)
    >>
    >> I'm thinking of something like :-
    >>
    >> Before the *Do Until* starts t0 = current time
    >>
    >> For each cycle within the loop t1 = current time and
    >> Cells(1,1,) = t1-t0
    >>
    >> But how?
    >>
    >> Many thanks
    >>
    >> Lisa
    >>
    >> BTW I'm using XL97
    >>

    >
    >




  7. #7
    moon
    Guest

    Re: VBA Timer

    I think you can't make it with only t0 and t1, you'll need t2 & t3 too...


    Public Sub YourSub()
    Dim t0, t1, t2, t3
    '5 seconds
    t0 = 5
    t1 = Timer
    Do While Timer < (t1 + t0)
    DoEvents
    t3 = (t1 + t0) - Timer
    Sheets(1).Cells(1, 1).Value = Round(t3, 0)
    Loop
    End Sub





    "Lisa" <[email protected]> schreef in bericht
    news:[email protected]...
    > Thanks Moon,
    > I appreciate your help but is there not a simpler way to achieve this?
    > I'm sure your code will work but I understand very little of it and , as
    > a newbie, I need to learn in small doses.
    >
    > Is it not possible to do it as I originally set it out?
    > i.e. at start t0 = current time
    > during loop t1 = current time
    > during loop shove the difference between t0 & t1 into a cell on the
    > worksheet
    >
    > As I said, I appreciate any help but I can't help feeling that there must
    > be a simpler way.
    >
    > Best Reagrds
    > Lisa
    >
    >
    > "moon" <[email protected]> wrote in message
    > news:[email protected]...
    >>
    >> Private Sub YourSub()
    >> Dim pTime, pStart, pEnd, tTime, lTime
    >> 'five seconds
    >> pTime = 5
    >> pStart = Timer
    >> Do While Timer < pStart + pTime
    >> DoEvents
    >> lTime = (pStart + pTime) - Timer
    >> 'update label (or anything else)
    >> timeLabel.Caption = Round(lTime, 0)
    >> Loop
    >> pEnd = Timer
    >> tTime = pEnd - pStart
    >> End Sub
    >>
    >>
    >>
    >>
    >> "Lisa" <[email protected]> schreef in bericht
    >> news:[email protected]...
    >>> Hi All,
    >>>
    >>> I'm looking for a simple timer routine that will show the time elapsed
    >>> for each cycle of a Do Until ...Loop instruction. (the loop can go on
    >>> for many millions of cycles)
    >>>
    >>> I'm thinking of something like :-
    >>>
    >>> Before the *Do Until* starts t0 = current time
    >>>
    >>> For each cycle within the loop t1 = current time and
    >>> Cells(1,1,) = t1-t0
    >>>
    >>> But how?
    >>>
    >>> Many thanks
    >>>
    >>> Lisa
    >>>
    >>> BTW I'm using XL97
    >>>

    >>
    >>

    >
    >




  8. #8
    moon
    Guest

    Re: VBA Timer

    I think you can't make it with only t0 and t1, you'll need t2 & t3 too...


    Public Sub YourSub()
    Dim t0, t1, t2, t3
    '5 seconds
    t0 = 5
    t1 = Timer
    Do While Timer < (t1 + t0)
    DoEvents
    t3 = (t1 + t0) - Timer
    Sheets(1).Cells(1, 1).Value = Round(t3, 0)
    Loop
    End Sub





    "Lisa" <[email protected]> schreef in bericht
    news:[email protected]...
    > Thanks Moon,
    > I appreciate your help but is there not a simpler way to achieve this?
    > I'm sure your code will work but I understand very little of it and , as
    > a newbie, I need to learn in small doses.
    >
    > Is it not possible to do it as I originally set it out?
    > i.e. at start t0 = current time
    > during loop t1 = current time
    > during loop shove the difference between t0 & t1 into a cell on the
    > worksheet
    >
    > As I said, I appreciate any help but I can't help feeling that there must
    > be a simpler way.
    >
    > Best Reagrds
    > Lisa
    >
    >
    > "moon" <[email protected]> wrote in message
    > news:[email protected]...
    >>
    >> Private Sub YourSub()
    >> Dim pTime, pStart, pEnd, tTime, lTime
    >> 'five seconds
    >> pTime = 5
    >> pStart = Timer
    >> Do While Timer < pStart + pTime
    >> DoEvents
    >> lTime = (pStart + pTime) - Timer
    >> 'update label (or anything else)
    >> timeLabel.Caption = Round(lTime, 0)
    >> Loop
    >> pEnd = Timer
    >> tTime = pEnd - pStart
    >> End Sub
    >>
    >>
    >>
    >>
    >> "Lisa" <[email protected]> schreef in bericht
    >> news:[email protected]...
    >>> Hi All,
    >>>
    >>> I'm looking for a simple timer routine that will show the time elapsed
    >>> for each cycle of a Do Until ...Loop instruction. (the loop can go on
    >>> for many millions of cycles)
    >>>
    >>> I'm thinking of something like :-
    >>>
    >>> Before the *Do Until* starts t0 = current time
    >>>
    >>> For each cycle within the loop t1 = current time and
    >>> Cells(1,1,) = t1-t0
    >>>
    >>> But how?
    >>>
    >>> Many thanks
    >>>
    >>> Lisa
    >>>
    >>> BTW I'm using XL97
    >>>

    >>
    >>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1