How to Create a Timer in VB2010


This is the very basic way on how to code or create your own timer using VB 2010, you must
add 2 Labels Control and 1 Timer control and also a 3 command button for you Handle whether
you want to start,stop and reset
















So this is the main code for you set up and get the output shown  in the image above, i used
the very basic Nested IF structure
.
 CODE:
 Place at the Timer1_Tick Event
Dim Uno, Dos As Integer

        Uno = "00"
        Dos = "09"

If Val(Label2.Text) >= Uno And Val(Label2.Text) < Dos Then
  Label2.Text = "0" & Val(Label2.Text) + 1      
   ElseIf Val(Label2.Text) = "59" Then
     If Val(Label1.Text) >= Uno And Val(Label1.Text) < Dos Then
         Label1.Text = "0" & Val(Label1.Text) + 1
         Label2.Text = "00"
      ElseIf Val(Label1.Text) = "11" And Val(Label2.Text) = "59" Then
          Label1.Text = "00"
          Label2.Text = "00"
       Else
         Label1.Text = Val(Label1.Text) + 1
       End If
  Else
       Label2.Text = Val(Label2.Text) + 1 
 End If

Download sample


Happy Coding ^_^
The Hardest Thing to Do is to Do Nothing
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

Leave a comment

Copyright @ Codes-47.Blogspot.Com. Powered by Blogger.