2015-10-26 113 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將不會保留小數值。

相關問題