Use the VB. NET stopwatch object to record the time

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.