help regarding timer

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 1
Reputation: icycool007 is an unknown quantity at this point 
Solved Threads: 0
icycool007 icycool007 is offline Offline
Newbie Poster

help regarding timer

 
0
  #1
Mar 15th, 2008
hello everyone i am trying to continue the countdown timer from 1 form to another in VB.NET but it is not working...
I have been able to run countdown timer but not able to continue it in the following pages
plz help me out as this project is very imp for me..

IN form
Timer1.Enabled = False

Label1.Text = "3:00.0"


If Not Timer1.Enabled Then
CountDownStart = Microsoft.VisualBasic.DateAndTime.Timer
Timer1.Enabled = True

Else
Timer1.Enabled = False
Label1.Text = "3:00.0"
Endif

In timer
Dim MinDiff
Dim SecDiff
Dim TenthDiff
Dim TimeDiff
TimeDiff = (1800) - Int((Microsoft.VisualBasic.DateAndTime.Timer - CountDownStart) * 10)
If TimeDiff >= 0 Then
TenthDiff = TimeDiff Mod 10
SecDiff = Int(TimeDiff / 10) Mod 60
MinDiff = Int(TimeDiff / 600)
Label1.Text = Format(MinDiff, "00") & ":" & Format(SecDiff, "00") & "." & Format(TenthDiff, "0")
Else
Label1.Text = "00:00.0"
Timer1.Enabled = False
MsgBox("!!!TIME!!!")
endif
Last edited by icycool007; Mar 15th, 2008 at 2:54 pm. Reason: providing the code
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,752
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 740
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: help regarding timer

 
0
  #2
Mar 15th, 2008
Here's an example of passing a timer between two forms:
  1. Imports System.Windows.Forms
  2.  
  3. Class Form1
  4. Inherits Form
  5.  
  6. Private _timer As Timer
  7.  
  8. Public Sub New()
  9. Me.Text = "Form 1"
  10.  
  11. Dim newForm As New Form2
  12.  
  13. _timer = New Timer
  14. _timer.Interval = 5000
  15.  
  16. AddHandler _timer.Tick, AddressOf TimerElapsed
  17.  
  18. newForm.MyTimer = _timer
  19. newForm.Show()
  20. End Sub
  21.  
  22. Private Sub TimerElapsed(ByVal obj As Object, ByVal e As EventArgs)
  23. _timer.Stop()
  24. MessageBox.Show("Timer elapsed from form 2")
  25. Application.Exit()
  26. End Sub
  27. End Class
  28.  
  29. Class Form2
  30. Inherits Form
  31.  
  32. Private _timer As Timer
  33.  
  34. Public Property MyTimer() As Timer
  35. Get
  36. Return _timer
  37. End Get
  38. Set(ByVal value As Timer)
  39. _timer = value
  40. _timer.Start()
  41. End Set
  42. End Property
  43.  
  44. Public Sub New()
  45. Me.Text = "Form 2"
  46. End Sub
  47. End Class
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC