VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Simple Timer Posted by dkislingbury on 2 Dec 2005 at 4:28 AM
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.
Report
Re: Simple Timer Posted by aamirwazir on 2 Dec 2005 at 1:34 PM
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.

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

Report
Re: Simple Timer Posted by dkislingbury on 6 Dec 2005 at 2:54 PM
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
Report
Re: Simple Timer Posted by aamirwazir on 7 Dec 2005 at 11:52 PM
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?
Report
Re: Simple Timer Posted by dkislingbury on 8 Dec 2005 at 1:45 AM
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
Report
Re: Simple Timer Posted by aamirwazir on 8 Dec 2005 at 3:03 AM
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 :)
Report
Re: Simple Timer Posted by dkislingbury on 8 Dec 2005 at 12:11 PM
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.
Report
Re: Simple Timer Posted by dkislingbury on 10 Dec 2005 at 2:30 AM
I have managed to fix the problem, so thanks for all your input mate
Report
Re: Simple Timer Posted by aamirwazir on 10 Dec 2005 at 3:10 AM
so how u did it ...
tell me too cuz i also saw this thing that the timer restarted...
but ignored it !
Report
Re: Simple Timer Posted by dkislingbury on 10 Dec 2005 at 4:31 AM
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.
Report
Re: Simple Timer Posted by eyad on 2 Jan 2006 at 7:00 AM
: 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.
:

Report
Re: Simple Timer Posted by dkislingbury on 2 Jan 2006 at 7:17 AM
I think we solved this issue.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.