Results 1 to 40 of 41

Thread: need help on my timer program[ResolveD]

Threaded View

  1. #7
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    HI,

    Cured it!!

    VB Code:
    1. Dim ZeroTime As Date    '  Form scope
    2. Dim RunTime As Date
    3. Dim EndTime As Date  ' depends on whether you are going
    4.                                        to use a time or a period
    5. Dim bTimer As Boolean = False
    6.  
    7.   Private Sub ButtonStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    8.  
    9.         ZeroTime = Format(CDate("00:00:00"), "HH:mm:ss")
    10.         RunTime=ZeroTime
    11.         Timer1.Enabled = True
    12.         Timer1.Interval = 1000
    13.  
    14.  
    15.     End Sub
    16.  
    17.  
    18.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    19.  
    20.   If bTimer = False Then
    21.         RunTime = RunTime.AddSeconds(1)
    22.         TextBox3.Text = (CStr(Format(RunTime, "HH:mm:ss")))
    23.         Here put code to check if EndTime has been reached or
    24.         passed.
    25.   End If
    26.  
    27.     End Sub
    28.  
    29.  Private Sub btnPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPause.Click
    30.         If btnPause.Text = "Pause" Then
    31.             btnPause.Text = "Resume"
    32.             bTimer = True
    33.         Else
    34.             btnPause.Text = "Pause"
    35.             bTimer = False
    36.         End If
    37.     End Sub

    If you want to count down then amend the appropriate line to

    RunTime = RunTime.AddSeconds(-1)
    Last edited by taxes; Nov 5th, 2004 at 09:52 AM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

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