.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Timer in VB.NET

Posted By:nishithraj       Posted Date: December 27, 2009    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

Following is the sample code for asynchronous timer control which works in an interval and stops

Imports System 
Imports System.Windows.Forms
Namespace TimerHelper 
    Public Partial Class Form1 
        Inherits Form 
        Private mTimerCtr As Integer = 0 
        Public Sub New() 
            timer1.Interval = 100 
            AddHandler timer1.Tick, AddressOf timer1_Tick 
        End Sub 
        Private Sub timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) 
            mTimerCtr += 1 
            Console.WriteLine("Timer ticked {0} times", mTimerCtr) 
            If mTimerCtr = 10 Then 
                Console.WriteLine("Stopping timer") 
            End If 
        End Sub 
    End Class 
End Namespace


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend