Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27072

VS 2010 [RESOLVED] Countdown Timer on a different form

$
0
0
Hello,

From Form1, I'm trying to Call a sub on Form2 that displays a countdown timer in a label.
First, I tried to it a different way by putting this code in Form1; above the sub "Dim tmrCD As Integer = 120" and code:

Code:

tmrCD = tmrCD - 1
                If tmrCD > 0 Then frmTwo.lblCD.Text = ("NEXT ATTEMPT STARTS IN " & tmrCD.ToString)
                If frmTwo.lblCD.Text = "0" Then
                    frmTwo.Timer1.Stop()
                End If

But it only displayed 119 and didn't count down. It was obvious to me that the reason is because the Timer is not being used.

Then I tried putting this into Form2

Code:

Private CD As Integer = 120

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        Me.lblCD.Text = ("NEXT ATTEMPT STARTS IN " & CD.ToString("00"))
        If CD = 0 Then
            Me.Timer1.Enabled = False
        Else
            CD -= 1
        End If
    End Sub

But it started counting down the instant the page loaded, which is completely opposite from what I need! I need Form1 to finish it's job when a button is pressed, THEN call Timer1_Tick at the bottom of the sub on Form1 when it's finished with it's job. In form1, I tried using:

Code:

Call frmTwo.Timer1
But got the error:

Quote:

Property access must assign to the property or use it's value.
I'm not sure how to proceed. Ideas?

Viewing all articles
Browse latest Browse all 27072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>