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

• June 23rd, 2013, 01:20 PM
sinankrstarica
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?
• June 23rd, 2013, 01:33 PM
dglienna
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
• June 23rd, 2013, 02:18 PM
sinankrstarica
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.
• June 24th, 2013, 12:36 AM
DataMiser
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.
• June 24th, 2013, 03:59 AM
sinankrstarica
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
• June 26th, 2013, 05:51 AM
GremlinSA
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 .....