Adblock breaks this site

stopwatch / countdown timer

Discussion in 'Programming General' started by mama luigi, May 6, 2010.

  1. mama luigi

    mama luigi Newcomer

    Joined:
    May 5, 2010
    Posts:
    11
    Referrals:
    0
    Sythe Gold:
    0
    stopwatch / countdown timer

    how would you make a stopwatch or a countdown timer, I can't seem to be able to figure out the code.

    Thanks in advance.
     
  2. Harlem9191

    Harlem9191 Member

    Joined:
    Mar 10, 2009
    Posts:
    81
    Referrals:
    0
    Sythe Gold:
    0
    stopwatch / countdown timer

    You would use a label and a timer.
    Declare a variable with an integer data type and make the variable hold the number you want it to start counting down from.
    Then in the tick event you would do:

    Variable = Variable - 1
    [Label].Text = Variable.ToString
     
  3. Harlem9191

    Harlem9191 Member

    Joined:
    Mar 10, 2009
    Posts:
    81
    Referrals:
    0
    Sythe Gold:
    0
    stopwatch / countdown timer

    Code:
    Dim intCountDown As Integer = 200   'The number you want to count down from here
    
    Private Sub tmrCountDown_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrCountDown.Tick
    
    intCountDown = intCountDown - 1   'Minus 1 off the varable
    
    lblCountDown.Text = intCountDown.ToString   'Display/update the variable in a label
    
    End Sub
    

    If you didn't understand what I said in my previous post then just copy the code I did above and just drag a label onto your form and call it 'lblCountDown'. Then drag a timer onto your form and call it 'tmrCountDown'.
     
< Microsoft DreamSpark Codes? | LOcate >


 
 
Adblock breaks this site