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

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
        newForm.Show()
    End Sub

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

Class Form2
    Inherits Form

    Private _timer As Timer

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

    Public Sub New()
        Me.Text = "Form 2"
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.