Timer Control Display Time

CoachBarker

Well-known member
Joined
Jul 26, 2007
Messages
133
Programming Experience
1-3
I have a timer on a form and I want it to count down from 90 seconds and when it hits 0 display a message box. I can get it to run but not from 90 seconds, it starts at 30.

I have declared a global variable
VB.NET:
Private gameTimeSpan As TimeSpan = TimeSpan.FromSeconds(90)

And in a sub
VB.NET:
Private Sub tmrPlay_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPlay.Tick
        Me.gameTimeSpan -= TimeSpan.FromMilliseconds(Me.tmrPlay.Interval)
        'displays the time in a label
        Dim display As String = Me.gameTimeSpan.Seconds.ToString()
        If Me.gameTimeSpan.Seconds = -1 Then
            tmrPlay.Stop()
            MessageBox.Show("Time has run out")
        End If
        Me.lblPlayTimeCounter.Text = display
    End Sub

How can I get it to start at 90 Seconds?

Thanks
CoachBarker
 
It is starting at 90 seconds, 90 seconds = 1 1/2 minutes = 1 minute 30 seconds. The time span will display in terms of minutes and seconds, over 59 seconds and it will add 1 to the minutes.
 
Is there a way then to get it to display the countdown from 90 seconds and not 1.30?

Thanks
CoachBarker
 
Back
Top