使用QTP我试图显示总时间但显示类型不匹配

时间:2017-06-02 08:04:45

标签: qtp

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

1 个答案:

答案 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