Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Displaying time

Displaying time

Scheduled Pinned Locked Moved Visual Basic
tutorial
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B bhattiprolu

    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....

    T Offline
    T Offline
    Tom Deketelaere
    wrote on last edited by
    #2

    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.

    1 Reply Last reply
    0
    • B bhattiprolu

      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....

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #3

      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 )

      T B 2 Replies Last reply
      0
      • C Christian Graus

        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 )

        T Offline
        T Offline
        Tom Deketelaere
        wrote on last edited by
        #4

        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.

        1 Reply Last reply
        0
        • C Christian Graus

          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 )

          B Offline
          B Offline
          bhattiprolu
          wrote on last edited by
          #5

          at timespan elapsed is giving me error (i am using VB.Net for coding)

          T D 2 Replies Last reply
          0
          • B bhattiprolu

            at timespan elapsed is giving me error (i am using VB.Net for coding)

            T Offline
            T Offline
            Tom Deketelaere
            wrote on last edited by
            #6

            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.

            B 1 Reply Last reply
            0
            • B bhattiprolu

              at timespan elapsed is giving me error (i am using VB.Net for coding)

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #7

              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

              1 Reply Last reply
              0
              • T Tom Deketelaere

                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.

                B Offline
                B Offline
                bhattiprolu
                wrote on last edited by
                #8

                how to show the progress as well...

                L 1 Reply Last reply
                0
                • B bhattiprolu

                  how to show the progress as well...

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #9

                  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


                  B 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    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


                    B Offline
                    B Offline
                    bhattiprolu
                    wrote on last edited by
                    #10

                    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.

                    L 1 Reply Last reply
                    0
                    • B bhattiprolu

                      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.

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #11

                      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


                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups