CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2013
    Posts
    14

    How to measure the time in tenths of a second in vb6

    Private Sub Timer1_Timer()
    TimerLbl.Caption = Format(Time - memTime, "hh:mm:ss")
    End Sub

    I need seconds and tenths of seconds. How? Which value to set Timer.Interval

    Since the program long stays in the loop, I do not implanted DoEvents because of the speed, the time often stands. Is it possible to somehow achieve that displays the time and it does not affect the speed of the program?

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to measure the time in tenths of a second in vb6

    1000 cycles = one second. Don't use anything less than 250 or it will corrupt the timer
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jun 2013
    Posts
    14

    Re: How to measure the time in tenths of a second in vb6

    Thanks to the appearance, but I am a beginner and I do not help. I know that 1000 cycles a second, but what I asked above - still do not know

    To set Timer.Interval clear to me and I did not know and I have often asked him to 100 (1/10 sec). Thank you.

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to measure the time in tenths of a second in vb6

    Setting a timer interval of 100 will not give you an accurate time.

    What you will get is a timer that is running a bit slower than you think. A setting of 100 means that it will try to fire about 10 times a second so in a perfect world that would be 1/10th second but the timer only fires when the program is not busy doing something else and can never be guaranteed to actually fire 10 times in a second. In any given second it may fire 10 times, it may fire 9 times or 2 times or not at all depending on what your program is doing. If nothing is going on in your program and you keep track of how many times the timer fires and compare that to the number of seconds that have past you will see that after it has ran for a few minutes it will already be several seconds off. The lower the interval the more it will be off.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jun 2013
    Posts
    14

    Re: How to measure the time in tenths of a second in vb6

    Maybe I do not even have to use a timer? I do not care to take the time displayed during operation. I want to measure how much the program is retained in a Function. So, in order to measure how much the computer kept Function I invited?


    ttTime = Time
    Call Function
    MyTime = Time - ttTime

    But, I need seconds and tenth of a second!
    How?
    Please can you give me some write code

  6. #6
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: How to measure the time in tenths of a second in vb6

    Code:
    Format(MyTime, "hh:mm:ss.nnn")
    Just include the Miliseconds in your output .....
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Tags for this Thread

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

Featured