Use the TIMER class to implement the "display time" function

xiaoxiao2021-03-06  110

The Timer class is a timer that implements an event in a user-defined time interval. Name Space: System.Windows.Forms Properties: Interval, get or set the time (in milliseconds) between the timer start timing, can be set to 1000 here, because the smallest unit of "display time" is second, 1 second Aliquot is equal to 1000 milliseconds. Method: START: Start timer Stop: Stop timer event: Tick: When the specified timer interval has passed, the timer is in an enabled state. ----------------------------- Source code -------------------------------------------------------------------------------------------------------------------------- --------------------------------- Source code end ------------- ---------- Top 6,7: Declare the two objects used in the program. Section 14-17: Place a Label object to display the time value of instant update. Chapter 19: Setting Timer's Interval Properties. The 20 sentence: the program to be executed when the Tick event occurs.第 21: Setting the current Timer object in the current Timer object using the enabled property. The 24th sentence: the NOW property of the DateTime structure, gets the current local date and time. Then use the toString () method to convert the DateTime type to the String type to assign the value to the TEXT property of the object LB1 to display the current time.

转载请注明原文地址:https://www.9cbs.com/read-97586.html

New Post(0)