Displaying time
-
Hi every one.. i have 2 buttons and one label.. if i click accept button time starts from 0 and if i click hangup button the label must dispaly how much time it hasd taken between two clicks.... can any body guide me how to achieve it....
-
Hi every one.. i have 2 buttons and one label.. if i click accept button time starts from 0 and if i click hangup button the label must dispaly how much time it hasd taken between two clicks.... can any body guide me how to achieve it....
put a timer on the form put timer interval at 1 sec on click of accept button start timer on every timertick you increase a global variable by 1 on click of hangup button stop timer do some calculating with the global variable and you know how much time past (I'm sure there are better ways to do this but don't have the time to look for one at the moment)
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.
-
Hi every one.. i have 2 buttons and one label.. if i click accept button time starts from 0 and if i click hangup button the label must dispaly how much time it hasd taken between two clicks.... can any body guide me how to achieve it....
A more accurate way than was suggested: DateTime start; button1Click { start = DateTime.Now; } button2Click { TimeSpan elapsed = DateTime.Now - start; } This approach is more accurate and simpler than playing with timers.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
A more accurate way than was suggested: DateTime start; button1Click { start = DateTime.Now; } button2Click { TimeSpan elapsed = DateTime.Now - start; } This approach is more accurate and simpler than playing with timers.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
yes it is thank you for correcting me ;P I knew there had to be a beter way but just couldn't think of it No sleep, long hours, lot's of stress and starting to get sick is starting to take its toll Thank God it's almost weekend
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.
-
A more accurate way than was suggested: DateTime start; button1Click { start = DateTime.Now; } button2Click { TimeSpan elapsed = DateTime.Now - start; } This approach is more accurate and simpler than playing with timers.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
at timespan elapsed is giving me error (i am using VB.Net for coding)
-
at timespan elapsed is giving me error (i am using VB.Net for coding)
dim elapsed as timespan = date.now - start should do it
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.
-
at timespan elapsed is giving me error (i am using VB.Net for coding)
That's because the code Christian posted is C#, not VB.NET. Though, it's easily translatable.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
dim elapsed as timespan = date.now - start should do it
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.
how to show the progress as well...
-
how to show the progress as well...
that would need a timer that ticks periodically (say every 100 msec) and updates the label to show the difference between now and start. :)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google
-
that would need a timer that ticks periodically (say every 100 msec) and updates the label to show the difference between now and start. :)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google
yup i have done that.... wat i need now is i want to display the time like continuously..... and after clicking hangup button it should show the total time it has taken to click the event.
-
yup i have done that.... wat i need now is i want to display the time like continuously..... and after clicking hangup button it should show the total time it has taken to click the event.
so do it. and if you need something new, read the relevant documentation and do some experiments. And only if that does not help, ask a specific question on CodeProject... :)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google