How do I format a timer in TestPartner so that I can read the elapsed time?

How do I format a timer in TestPartner so that I can read the elapsed time?

TestPartner has three timer systems available to it:-

1. The TestPartner internal system (the TClock object)

2. The operating system's clock by calling the VBA 'Now' method

3. The high precision VBA Timer object.

The first two present the elapsed time in a format that is not immediately readable or useable.The high precision timer would be most suitable for timing the execution of a script or part of a script.

The following short TestPartner script takes each of these timer systems and outputs a formatted result to a messagebox. Methods (1) and (3) present the result only in seconds and fractions of a second, so if your timer is going to exceed one minute you may wish to add further code to produce an hh:mm:ss formatted output.

Sub Main()

' TestPartner Native in seconds and fractions
Dim tc As TClock
Set tc = Clock("myClock")
MsgBox "Time format test - Testpartner Native - 3 secs"
Pause 3, tpPauseSeconds
MsgBox (CStr(tc.Elapsed / 1000))

' Operating system time in whole seconds
MsgBox "Time format test - O/S - 2 secs"
Start = Now
Pause 2, tpPauseSeconds
Finish = Now
MsgBox (Format(Finish - Start, "hh:mm:ss"))

' High precision in seconds and fractions
MsgBox "Time format test - VBA timer - 4 secs"
Start = Timer
Pause 4, tpPauseSeconds
Finish = Timer
MsgBox (Finish - Start)

End Sub


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Version history
Revision #:
1 of 1
Last update:
‎2014-09-23 20:18
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.