本文介绍了now.ticks不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 将它放在一个填充列表框的按钮后面。 因为你会看到时间现在然后是0或填写????????????? > 按下按钮。 有没有办法确定实际经过的时间? 谢谢,Willie Dim T As Double T = Now.Ticks System.Threading.Thread.Sleep (3) T = Now.Ticks - T ListBox1.Items.Insert(0,T.ToString(" 0000000000000000" )) 解决方案 Now.Ticks的*单位*为100纳秒。 *分辨率*为AFAIR 0.01秒。 睡眠时间超过0.01秒,你会看到差异。 更高分辨率:环境。吸盘。 甚至更高的分辨率:高性能计数器。 (参见 QueryPerformanceCounter和QueryPerformanceFrequency API函数) Armin 2005年8月17日星期三15:41:31 +0200,Willie jan写道: 不确定你的代码有什么问题,但是这就是我要做的事情: Dim T as DateTime T =现在 System.Threading.Thread.Sleep(3) Dim D作为TimeSpan D = Now.Subtract(T ) ListBox1.Items.Insert(0,D.ToString()) 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")) 解决方案 The *unit* of Now.Ticks is 100 nano seconds.The *resolution* is AFAIR 0.01 seconds. Sleep longer than 0.01 seconds and you''ll see a difference. Higher resolution: Environment.Tickcount.Even higher resolution: High performance counter. (seeQueryPerformanceCounter and QueryPerformanceFrequency API functions) Armin 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()) 这篇关于now.ticks不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 22:57