Countdown Timer

Countdown Timer

Page 1 of 1

4 Replies - 1492 Views - Last Post: 29 January 2009 - 11:03 AM Rate Topic: -----

#1 wailedekim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-January 09

Countdown Timer

Posted 29 January 2009 - 10:35 AM

I'm sorry I do not have any code yet, because I have no clue how to do this, but I have a game and you can select amount of time to play the game for and I want to display a timer with the amount fo time you have left. The timer currently will just end the game and display a messagebox when the time is out.

Thanks in advance for the help.

Matt.
Is This A Good Question/Topic? 0
  • +

Replies To: Countdown Timer

#2 wailedekim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-January 09

Re: Countdown Timer

Posted 29 January 2009 - 10:40 AM

Note: i am Using vb.net 2005
Was This Post Helpful? 0
  • +
  • -

#3 Jeggred  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 28-January 09

Re: Countdown Timer

Posted 29 January 2009 - 10:50 AM

View Postwailedekim, on 29 Jan, 2009 - 10:35 AM, said:

I'm sorry I do not have any code yet, because I have no clue how to do this, but I have a game and you can select amount of time to play the game for and I want to display a timer with the amount fo time you have left. The timer currently will just end the game and display a messagebox when the time is out.

Thanks in advance for the help.

Matt.


To display a Timer in a Label you need to declare an integer and set its value equal to the time you want to start off with. After that you need to make a timer and set the interval to 1000, this will equal 1 second, afterwards in the Timer tick event you will need to do this.
	Dim GameTime as Integer = 90 'the time you want to start the game off as
   Private Sub tmrTotalTime_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrTotalTime.Tick
		GameTime -= 1 'will decrease the Integer by 1 every second
		lblGameTime.Text = GameTime.ToString

	End Sub

To end the game just use an if statement to check to see if GameTime equals 0 and put the correct code that follows
Was This Post Helpful? 0
  • +
  • -

#4 wailedekim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-January 09

Re: Countdown Timer

Posted 29 January 2009 - 11:00 AM

Thank you Jeggred!
Was This Post Helpful? 0
  • +
  • -

#5 Jeggred  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 28-January 09

Re: Countdown Timer

Posted 29 January 2009 - 11:03 AM

Anytime :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1