VBA 如何计算一段代码运行需要的时间?
更精准
Private Sub Form_Load()
Dim sngStart As Single
sngStart = Timer
'循环代码
Debug.Print "耗费时间: " & Timer - sngStart更精准
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Form_Load()
Dim dt As Longdt = GetTickCount
'循环代码
Debug.Print "用时:" & GetTickCountd - dtEnd Sub
本文介绍了两种使用VBA测量代码运行时间的方法。一种是利用内置的Timer函数,另一种是通过调用Windows API GetTickCount函数来获取更为精确的时间间隔。
1779

被折叠的 条评论
为什么被折叠?



