• Elapsed Time Function – Update

    Author
    Topic
    #353393

    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.

    http://www.mvps.org/ccrp/

    Viewing 1 reply thread
    Author
    Replies
    • #516850

      … 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.

    • #516759

      [indent]


      Edit : The information in this post regarding an undocumented feature (the :ms Format() function expression) is incorrect. Please see post by Timbo below for a solution that works. Kevin regrets any harm that may have come to your children due to his error


      [/indent]

      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.ms“)

      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 CCRP Timer Control, 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…

      • #521561

        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

        • #521571

          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.

          • #521576

            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.

            • #521577

              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.

      • #550874

        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.

        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
        
        • #550945

          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.

        • #551196

          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.

          • #551467

            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.

    Viewing 1 reply thread
    Reply To: Elapsed Time Function – Update

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: