Timer in Visual Basic .Net

Download
Download is available until [expire_date]
  • Version
  • Download 66
  • File Size 104.90 KB
  • File Count 1
  • Create Date March 8, 2016
  • Last Updated March 8, 2016

Timer in Visual Basic .Net

Timer in Visual Basic .Net

Sample source code on how to use timer control in visual basic .net

Source code:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()
        Label2.Text = "Timer Started"
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = Label1.Text + 1
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Button2.Text = "Stop Timer" Then
            Button2.Text = "Resume Timer"
            Timer1.Stop()
            Label2.Text = "Timer Stopped"
        ElseIf Button2.Text = "Resume Timer" Then
            Button2.Text = "Stop Timer"
            Timer1.Start()
            Label2.Text = "Timer Resumed"
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Label1.Text = 0
        Label2.Text = "Timer has been reset.Please start timer again"
        Timer1.Stop()
    End Sub
End Class
, , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.