ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

23-Timers

In Visual Basic, Timer is design to control the time and to allow the users manipulate a certain task. For instance, when you create a clock , a stopwatch or any task that tells times, a time control is needed.

 

Example:

  1. Open the Visual Basic, select “File” on the menu, hit new and create a new project.
    01_helloworld
  2. The New Project dialog will appear.
    create2s
    Select “windows” in the project types, hit the “windows form application” in the templates and hit “ok“.
  3. Design the form this way. See it Below.
    f1
  4. Double click the Timer to fire the tick event handler of it and do this following code.
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2. Label1.Text = TimeOfDay
    3. End Sub
  5. Add this following code for to start the timer on the first load of the form
    1. Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    2. Timer1.Start()
    3. End Sub

Output:

f2

Facebook Comments

Check Your Domain Ranking

Leave a Reply

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

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!