Simple Timer - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Simple Timer

dkislingburydkislingbury Posts: 16Member
By mate has asked me to try to fiqure this out for him, but I don't have a clue where to begin, any of you guys any points whihc would point him in teh right direction.

He is looking to click a button whihc then takes him to another screen and automatically starts a timer (mm:ss). He wants to continue going through frames until he selects the finish button on the last frame which then shows the time it took him to get to that point.

Cheers.
«1

Comments

  • aamirwaziraamirwazir Posts: 108Member
    now u need 3 thngs probably

    1)Timer (Available in the tool box) Named as "Timer1" in code
    u have to make ur Timer`s Interval To 1000 instead of 100 in the property window of timer1

    2) Label (Which will show the Time) Named as "lblTimeElapsed" in the code

    3) Two Member Variables
    * Sec
    * Min and both as double so here is wat u need to do

    4) A button (Finish Button) named as btnFinish in the code.

    [code]
    Dim sec As Double = 0.0
    Dim min As Double = 0.0
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Timer1.Start()
    End Sub

    Private Sub btnFinish_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFinish.Click
    Timer1.Stop()

    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    sec = sec + (Timer1.Interval / 1000)
    If sec = 60 Then
    min += 1
    sec = 0
    End If
    lblTimeElapsed.Text = min.ToString() & " : " & sec.ToString()
    End Sub
    [/code]
  • dkislingburydkislingbury Posts: 16Member
    Thanks for that, works really well. One thing, I can't seem to be able to adapt it so that it will carry on display the time when i go onto other frames and then select the finish button on teh last frame, five frames after the one it is initialised on.

    Thanks again. David
  • aamirwaziraamirwazir Posts: 108Member
    i couldnt understand wat exactly u r tryin to say
    is it tht u want this timer to be played when other forms are opened as well?
  • dkislingburydkislingbury Posts: 16Member
    Well I have one form which I want the timer to be initialised in. On that form there is a button saying 'next' which takes you to the next form, and thsi goes on for five times. On the final form you reach I want a button called finished which stops the timer. I would also like the timer to be displayed in each frame as you go along.

    Thanks
  • aamirwaziraamirwazir Posts: 108Member
    hmm
    well i hope it works... im not sure but....here`s wat u have to do
    make a new form (lets say Form1) and only place a timer on it
    the next forms u make
    go to
    Project-----> Add Inheritede Form
    and select Form1 as the parent
    now the timer will be displayed on each form
    i hope it works :)
  • dkislingburydkislingbury Posts: 16Member
    The timer is displayed on the other frame which is inheriting from the initial one but the timer resets when ever you go to it.
  • dkislingburydkislingbury Posts: 16Member
    I have managed to fix the problem, so thanks for all your input mate
  • aamirwaziraamirwazir Posts: 108Member
    so how u did it ...
    tell me too cuz i also saw this thing that the timer restarted...
    but ignored it !
  • dkislingburydkislingbury Posts: 16Member
    I was still getting teh restart, so I adapted teh program to show a different time for each frame and then let teh user compare teh two. This made mroe sense for teh programs needs. Will keep on trying ot fiqure out teh restart thing though. I would have thought logically that through inheritence it would have keeped on timing teh same timer.
  • eyadeyad Posts: 1Member
    : By mate has asked me to try to fiqure this out for him, but I don't have a clue where to begin, any of you guys any points whihc would point him in teh right direction.
    :
    : He is looking to click a button whihc then takes him to another screen and automatically starts a timer (mm:ss). He wants to continue going through frames until he selects the finish button on the last frame which then shows the time it took him to get to that point.
    :
    : Cheers.
    :

«1
Sign In or Register to comment.