Make a timer in vb

Discussion in 'Programming General' started by iwanttoauto, Apr 9, 2008.

Make a timer in vb
  1. Unread #1 - Apr 9, 2008 at 7:24 PM
  2. iwanttoauto
    Referrals:
    0

    iwanttoauto Guest

    Make a timer in vb

    I am working on a custom client and i need to add a timer that displays the time the user has been on.
    I am using vb.net 2008 express.

    I've tried everything

    Any help? I've tried to Google it as well.
     
  3. Unread #2 - Apr 17, 2008 at 11:17 AM
  4. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    Make a timer in vb

    Lol nice your like me here,
    Label as the time the person has been on - Label1
    Button as starter for timer - Button1

    1. At the top of your form's code beneath Public Class (Form1) put,

    Code:
    Dim Time as integer = 0
    2.under timer tick event (Double click the timer) put this code,
    And in properties box when you've clicked the timer once to the right the property that says Interval change to 1000 (1 second in mille seconds)
    Code:
    Time += 1
    Label1.text = Time
    there that will make the label go 1,2,3,4,5,6,7,8,9,10 etc. once it gets to 60,61,62 so if you want it to go 59,1:00,1:01 then tell me.
     
  5. Unread #3 - Apr 17, 2008 at 12:26 PM
  6. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    Make a timer in vb

    It would be better to use a StopWatch since it is much more accurate.

    Under the timer's Tick event, you could just use this code.
    Code:
    Static Watch As Stopwatch = Stopwatch.StartNew
    Dim Time As String = Watch.Elapsed.ToString.Split("."c)(0)
    If Label1.Text <> Time Then Label1.Text = Time
    
    Also, Static means that the variable will keep the exact same value every time the method is called.
     
< Released RS [VB6] Projects | ok.., so how do I navigate the internet???? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site