-
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"
HELP?
-
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:
Code:
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
Else
lblTimer.Text = "Boom!"
End If
End Sub
End Class
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Similar Threads
-
By jonyBravo in forum AJAX
Replies: 1
Last Post: 08-06-2008, 07:37 AM
-
Replies: 1
Last Post: 06-23-2008, 11:17 AM
-
By teja8100 in forum VB Classic
Replies: 7
Last Post: 05-18-2005, 09:44 AM
-
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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|