Dim Starttime,Endtime,Totaltime
Starttime = FormatDateTime (Time, vbShortTime)& Right (Time, 6) ' Full 24 hour time format
msgbox starttime
Endtime = FormatDateTime (Time, vbShortTime)& Right (Time, 6) ' Short 24 hour time format
msgbox Endtime
Totaltime = Starttime-Endtime
msgbox Totaltime
答案 0 :(得分:2)
而是使用MercuryTimers对象,它为您提供更多控件,如开始,停止,重置,继续。
MercuryTimers("Timer1").Start
...
'YOUR CODE
...
MercuryTimers("Timer1").Stop
Totaltime = MercuryTimers("Timer1").Elapsedtime/1000
If Totaltime > 60 Then
tempTime = Totaltime/60
Temp_Arr = split(tempTime,".",-1,1) : Temp2 = "." & Temp_Arr(1)
msgbox Temp_Arr(0) & " Min, " & Round(Temp2 * 60) & " Sec"
Else
msgbox Totaltime & " Sec"
End If