Results 1 to 11 of 11
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    I should have mentioned that CCRP has an outstanding Timer Control that facilitates calculating elapsed time. The control is written by Karl E. Peterson

    Credit where credit is due!

    But as my son would say, No credit. Cash only.

    <A target="_blank" HREF=http://www.mvps.org/ccrp/>http://www.mvps.org/ccrp/</A>
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    ... also that StartTime is really TimeStart (grin!).

    Is this another excuse for me to plug the OPTION EXPLICIT statement? (vbg!)



    Kevin, thanks for this. With your permission I'd like to add it to my Utility template. With your name in lights. Or at least, in Courier 10pt.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    OK. You're the public TIMER expert. I grabbed a copy of your efforts, for which thanks.

    Is this the most precise time I can expect to capture in Word97SR2/VBA or are you aware of an even finer time.

    I suspect that milliseconds will do me for now, but if there were a Micro-second or chunks-of, I'd as well use that.


    Nothing urgent. Just get back to me by 5pm.


    On mille-second thoughts, make that 17:00:00.000

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    Better check out CCRP Timer Control. Don't know if it gives you nano or pico seconds, but I know it does milli just fine.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    Sheesh, Kevin. One hour 3 minutes late. Tut tut!

    Still 'n'all thanks for the reminder. I am grabbing a copy from the page linked in a message up back ther above this oen.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    Hey, man cut me some slack. I was at the dentist this am. They don't have IP terminals there. Not a bad idea, though, for a new company: Put doctor, dentist, etc offices on the net for patrons to use in the waiting room. The money saved on magazine subscriptions would help pay for the service. You heard it first right here on Woody's Lounge.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    Well, you're right. That ain't milliseconds is it...

    Upon further testing I discover that :ms gives me the month +1 then the right most seconds digit.

    Thanks for your careful eye and for the correction.

    Nice function too.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Elapsed Time Function - Update

    <hr>Edit : The information in this post regarding an undocumented feature (the :ms Format() function expression) is incorrect. Please see post by <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=vb&Number=90781&page=0& view=collapsed&sb=5&o=0&vc=1#Post90781>Timbo</A> below for a solution that works. Kevin regrets any harm that may have come to your children due to his error<hr>

    I discovered what appears to be an undocumented item that solved (I think it solved) my problem: how to calculate an elapsed time and display the results with milliseconds.

    TimeStart = Time
    .
    .
    .Do the loop, etc.
    .
    .
    TimeLapsed = Time - TimeStart
    txtTimer.Text = Format(TimeLapsed, "ss.<font color=red>ms</font color=red>")

    The "undocumented" item is the 'ms' in the format statement. I could find nothing about this in VBA help, MSDN or any number of sites. But while looking at the <A target="_blank" HREF=http://www.mvps.org/ccrp>CCRP Timer Control</A>, I noticed they used the VB Format statement with ms for milliseconds. I tried it and it works in VBA.

    Just thought you might like to know...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  9. #9
    5 Star Lounger Ruff_Hi's Avatar
    Join Date
    Feb 2001
    Location
    New York, New York, USA
    Posts
    768
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    Are you sure? I used format(time, "ss.ms") and all it gave me was the number of seconds follows by a dot followed by the month number followed by the number of seconds again.

    Sort of like 33.1133.

    I put together the following which gives me hh:mm:ss.milliseconds and seems to work ok.

    <pre>Dim lrTimer As Double
    Dim lrCurrTime As Double
    Dim lrMilliseconds As Double

    lrTimer = Timer
    lrMilliseconds = lrTimer - Int(lrTimer)
    lrCurrTime = int(lrTimer) / (24& * 60& * 60&)

    msgbox Format(lrCurrTime, "hh:mm:ss") & _
    Format(lrMilliseconds, ".00 - ") & _
    Message
    </pre>

    (Location Australia, then UK, but now USA. Heart, outlook, attitude, etc always Australian)
    Quote: "All Happiness is the release of internal pressure"

  10. #10
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    I haven't tried your code, but it does not look like it will give you what you are looking for. The first thing that I see is that you are getting a two digit milliseconds, and that does not make sense. There are 1,000 milliseconds in a second. What you are actually displaying is hundredths of a second, not milliseconds.

    You don't say what Timer contains. If it contains seconds, the the rest of your code makes sense. However, if it contains a DateTime value, the rest of the code does not give you what you say it does.
    Legare Coleman

  11. #11
    5 Star Lounger Ruff_Hi's Avatar
    Join Date
    Feb 2001
    Location
    New York, New York, USA
    Posts
    768
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Elapsed Time Function - Update

    Yes, you are quite correct, it should be deciseconds, not milliseconds. With regards to timer, its a VB / VBA function that comes with the language. Do I have to describe it. Oh ok, here is what I lifted out of the help ...

    Returns a Single representing the number of seconds elapsed since midnight.
    (Location Australia, then UK, but now USA. Heart, outlook, attitude, etc always Australian)
    Quote: "All Happiness is the release of internal pressure"

Posting Permissions

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