Saturday, 28 January 2012

vb.net code for timer?


How to use timer in vb.net?
This tutorial you can learn how to play with timer in vb.net?
Step1:
Open Microsoft visual studio
Step2:
Open file newà windows form application àrename it as timer
Step3:
Drag and drop the one text box, two buttons, timer, and one label
Step4:
Write or copy the below code on program window
Code:
Public Class Form1

    Private SubTimer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesTimer1.Tick
        TextBox1.Text = TextBox1.Text + 1
    End Sub

    Private Sub Button1_Click(ByValsender As System.Object, ByVal e AsSystem.EventArgs) HandlesButton1.Click
        Timer1.Start()
      

    End Sub

    Private SubButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton2.Click
        Timer1.Stop()
    End Sub
End Class

Output: