Re: now.ticks does not work



On Wed, 17 Aug 2005 15:41:31 +0200, Willie jan wrote:

> place this behind a button that fills a listbox.
> as you will see the time is now and then 0 or filled in????????????
> by hitting the button.
>
> is there a way to determine the real elapsed time?
>
> thanks, Willie
>
> Dim T As Double
>
> T = Now.Ticks
>
> System.Threading.Thread.Sleep(3)
>
> T = Now.Ticks - T
>
> ListBox1.Items.Insert(0, T.ToString("0000000000000000"))

Not sure what's wrong with your code, but here's what I would have done:

Dim T as DateTime

T = Now

System.Threading.Thread.Sleep(3)

Dim D as TimeSpan

D = Now.Subtract(T)

ListBox1.Items.Insert(0, D.ToString())
.