An easy way to determine how long it has taken since a specific time point in an application is to use the system. Diagnostics. Stopwatch object, which has been added to Visual Basic 2005. It provides precise time loops and blocks.CodeIt is useful when you need to accurately measure the elapsed time.
To use the stopwatch object, you need to call its start and end methods. When the start method is called, the object starts timing. (If you need to clear the stopwatch Count value, the resetting method will be very useful ).
The example in list A demonstrates how to use the stopwatch object. When the message box prompts you to click OK, when you are ready to view the elapsed time, wait for a few minutes and click OK. You will see a message showing the number of seconds that have elapsed since stpwatchinfo.
The following are some examples:
In this example, I created the stpwatchinfo variable as a stopwatch object. Then I use the start method of the object to start the object to track the recorded time. After clicking the OK button in the Start message box, we use the elapsed attribute of the object to set the time value in seconds by using the stpwatchinfo. elapsed. Seconds attribute. The result displays the number of seconds that have elapsed since the stopwatch object was started.