DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Uh, timer countdown

  1. #1
    Join Date
    Dec 2008

    Uh, timer countdown

    I think I'm doing VERY basic VB 2005 right now for school.

    I'm trying to make my final project a time bomb, and it needs to countdown from 60.
    I'm practicing for it, and I don't know how to get this timer working.

    I did this, I thought it would work, but it didn't quite.
    It takes forever to countdown.
    Timer interval = 10000

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If Timer1.Interval = 10000 Then
    Me.lblTimer.Text = "10"
    ElseIf Timer1.Interval = 9000 Then
    Me.lblTimer.Text = "9"
    ElseIf Timer1.Interval = 8000 Then
    Me.lblTimer.Text = "8"
    ElseIf Timer1.Interval = 7000 Then
    Me.lblTimer.Text = "7"
    ElseIf Timer1.Interval = 6000 Then
    Me.lblTimer.Text = "6"
    ElseIf Timer1.Interval = 5000 Then
    Me.lblTimer.Text = "5"
    ElseIf Timer1.Interval = 4000 Then
    Me.lblTimer.Text = "4"
    ElseIf Timer1.Interval = 3000 Then
    Me.lblTimer.Text = "3"
    ElseIf Timer1.Interval = 2000 Then
    Me.lblTimer.Text = "2"
    ElseIf Timer1.Interval = 1000 Then
    Me.lblTimer.Text = "1"


  2. #2
    Join Date
    Nov 2003
    Portland, OR
    The timer's interval determines how often the Tick event will execute. If you want it to execute once per second, set the interval to 1000 milliseconds and don't change it. In the Tick event procedure, you need to have a variable that counts down the number of seconds remaining:
    Public Class Form1
        Private SecondsRemaining As Integer = 10
        Private Sub Timer1_Tick(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles Timer1.Tick
            If SecondsRemaining > 1 Then
                SecondsRemaining -= 1
                lblTimer.Text = SecondsRemaining
                lblTimer.Text = "Boom!"
            End If
        End Sub
    End Class
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    Moved To .NET

Similar Threads

  1. Ajax countdown timer
    By jonyBravo in forum AJAX
    Replies: 1
    Last Post: 08-06-2008, 07:37 AM
  2. C++ Timer Not working
    By seanko0 in forum C++
    Replies: 1
    Last Post: 06-23-2008, 11:17 AM
  3. Problem with Timer object
    By teja8100 in forum VB Classic
    Replies: 7
    Last Post: 05-18-2005, 09:44 AM
  4. Timer
    By Tomas in forum ASP.NET
    Replies: 0
    Last Post: 05-22-2002, 01:10 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center