Ask a Question

Change the formatting of StopWatch.ToString() output

Frequent Contributor

Change the formatting of StopWatch.ToString() output


I'm using StopWatch object on my UserForms, and to get the execution time, I use StopWatch.ToString() after the watch stops.

Current format of the output string is as given below - 


Test1 finished. Execution time: 00:00:05.000


I want to change the format to HH:MM:SS. Any suggestions would be appreciated.


Note: I've tried  using aqConvert util but didn't help.


Thank you


Esteemed Contributor

The "Stop" method returns an integer of the number of milliseconds passed.  You can convert that to whatever you want to by doing the necessary math.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Showing results for 
Search instead for 
Did you mean: