Learn how to Make Money Online | Free Tech Magazines
Go4Expert
Go4Expert RSS Feed

Go Back   Programming and SEO Forum >  Go4Expert > Articles / Source Code > Programming > Visual Basic [VB]

Discuss / Comment Copy HTML to Clipboard  Copy BBCode to Clipboard  Add to del.icio.us  Add to Google  Digg it  Add to Yahoo !  Add to Windows Live  Add to Facebook  Add to StumbleUpon 
 
Bookmarks Article Tools Search this Article Display Modes

Perform periodic operations with VB.Net's Timer control

By pradeep pradeep is offline

On 27th March, 2007
Lightbulb Perform periodic operations with VB.Net's Timer control

ADVERTISEMENT
Show Printable Version Email this Page Subscription Add to Favorites Copy Perform periodic operations with VB.Net's Timer control link

Author

pradeep ( Team Leader )

Yet to provide details about himself


All articles By pradeep

Recent Articles

Similar Articles

Developers are often required to make a specific action take place on a form on a regular basis or after a set time interval. One way you can achieve this functionality is by using VB.NET's Timer control.

Example

One of the best ways to understand how the Timer control works is with an example. Follow these steps:

1. Add a Timer control (which is available under the Components section) to your form and call it Timer1.
2. Set its Interval property to 1000 and its Enabled property to True.
3. Add a Label control to your form, call it lblDateTime, and set its Text property to "".
4. Add the following code:

Code: VB
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
     Handles Timer1.Tick
     lblDateTime.Text = Now.ToLongTimeString.ToString()
 End Sub
When you run the code, the date/time value displayed on the form is updated periodically.

Explanation

The Timer1_Tick event is fired once the time specified in the Interval property passes. Since the code I execute on this event simply updates the lblDateTime's Text property with the current Date/Time value, the Date/Time displayed on the form is updated every 1,000 milliseconds (as specified in the Timer1's Interval property).
Discuss / Comment Copy HTML to Clipboard  Copy BBCode to Clipboard  Add to del.icio.us  Add to Google  Digg it  Add to Yahoo !  Add to Windows Live  Add to Facebook  Add to StumbleUpon 


Currently Active Users Reading This Article: 1 (0 members and 1 guests)
 
Article Tools Search this Article
Search this Article:

Advanced Search
Display Modes
Bookmarks

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads / Articles
Thread Thread Starter Forum Replies Last Post
TextBox Control in C# Sanskruti C# 0 03-07-2007 07:37 PM

 

All times are GMT +5.5. The time now is 05:09 AM.