Results 1 to 2 of 2

Thread: timer and text alternation

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2012
    Posts
    1

    timer and text alternation

    hey guys so i made a timer that counts down from 15 to 0 ,
    now i need a text displaying timer has finished on the aplication when
    timer = "0" ,,, how to do? thanks

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: timer and text alternation

    Declare module level variable and decrease it in Tick event and when it reach 0, display the message.
    Something like this
    vb Code:
    1. Public Class Form1
    2.     Private mintCounter As Integer
    3.  
    4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.         mintCounter = 15
    6.         Timer1.Interval = 1000 ' one second
    7.         Timer1.Enabled = True
    8.     End Sub
    9.  
    10.     Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    11.         mintCounter -= 1
    12.         Me.Text = mintCounter
    13.         If mintCounter = 0 Then
    14.             Timer1.Enabled = False
    15.             MessageBox.Show("Timer has been finished")
    16.         End If
    17.     End Sub
    18. End Class



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width