如果,你这个不是简单的一次计算耗时的话,我建议您把上面2或3楼的回答问题中的 Timer 改为 Windows API 函数 GetTickCount ,它比较可靠,因为一旦在执行过程中系统时间被人改掉了,那么 Timer 的差值就会变了!'GetTickCount 函数的声明:Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Option ExplicitPrivate Sub Command1_Click() Dim StartTime As Date, i As Long StartTime = Now() For i = 1 To 32767 Label1.Caption = "用时:" & DateDiff("S", StartTime, Now()) & "秒!" List1.AddItem i DoEvents Next End Sub
Option ExplicitPrivate Sub Command1_Click()
Dim StartTime As Date, i As Long
StartTime = Now()
For i = 1 To 32767
Label1.Caption = "用时:" & DateDiff("S", StartTime, Now()) & "秒!"
List1.AddItem i
DoEvents
Next
End Sub