eHow launches Android app: Get the best of eHow on the go.

How To

How to Program the Timer Control in VB.net

Member
By Mike
User-Submitted Article
(4 Ratings)
VB.net
VB.net

The timer control allows you to set specific time intervals until some code has to be executed. Here is how you program the timer control in VB.net

Difficulty: Easy
Instructions

Things You'll Need:

  • VB.net
  1. Step 1

    Open VB.net and create a new windows application.

  2. Step 2
    Listbox
     
    Listbox

    Add a listbox to the form. We are going to use the listbox to add items to it every time the timer control gets exceuted.

  3. Step 3
    Timer Control
     
    Timer Control

    Add the timer control to your form. Notice how the timer control is not actually shown on the form but instead in a different panel at the bottom.

  4. Step 4
    Timer Properties
     
    Timer Properties

    Click on the timer control and press the F4 key to bring up the timer's property window.

  5. Step 5
    Enabled Property
     
    Enabled Property

    Change the timer's enabled property from false to true.

  6. Step 6
    Interval Property
     
    Interval Property

    Chaneg the timer's interval property to 1000 which is about one second.

  7. Step 7
    Tick event
     
    Tick event

    Double click the timer control to bring up the timer's tick event.

  8. Step 8
    Code
     
    Code

    In the tick event we are going to add the code:
    ListBox1.Items.Add(ListBox1.Items.Count)

    What this does is add to our listbox the number of items in the listbox each time the tick event executes which we set earlier to 1000 or about every second.

  9. Step 9

    Run the program by pressing the F5 key on your keyboard.

  10. Step 10
    Final Results
     
    Final Results

    Notice how the numbers get added to the listbox.

Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy .   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. † requires javascript

eHow Computers
eHow_eHow Technology and Electronics