Start New Discussion within our Software Development Community

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

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

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")
Label1.Text = "00:00.0"
Timer1.Enabled = False

Here's an example of passing a timer between two forms:

Imports System.Windows.Forms

Class Form1
    Inherits Form

    Private _timer As Timer

    Public Sub New()
        Me.Text = "Form 1"

        Dim newForm As New Form2

        _timer = New Timer
        _timer.Interval = 5000

        AddHandler _timer.Tick, AddressOf TimerElapsed

        newForm.MyTimer = _timer
    End Sub

    Private Sub TimerElapsed(ByVal obj As Object, ByVal e As EventArgs)
        MessageBox.Show("Timer elapsed from form 2")
    End Sub
End Class

Class Form2
    Inherits Form

    Private _timer As Timer

    Public Property MyTimer() As Timer
            Return _timer
        End Get
        Set(ByVal value As Timer)
            _timer = value
        End Set
    End Property

    Public Sub New()
        Me.Text = "Form 2"
    End Sub
End Class
This article has been dead for over six months. Start a new discussion instead.