2015-10-26 115 views
1

我想把一个计时器放入excel中的宏。我遵循教程,但是,计时器始终将运行时间设置为0秒。我知道我写的东西的时间复杂度很小,但是我会认为它仍然会在几秒或十分之一秒左右。在excel中创建一个计时器,在运行时显示十分之几秒钟hundreths

在这种情况下Excel是否舍​​入?

'For me to keep track of time complexity 
Dim StartTime As Long 
Dim SecondsElapsed As Long 
StartTime = Timer 

随后代码在子

'Timer runs to give lifespan of operation 
SecondsElapsed = Round(Timer - StartTime, 2) 
Cells(24, 4).Value = "This took " & SecondsElapsed & " seconds to run" 

回答

2

变化StartTimeSecondsElapsed数据类型到DoubleLong将不会保留小数值。

相关问题