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

Timer

Scheduled Pinned Locked Moved Visual Basic
question
7 Posts 6 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.
  • A Offline
    A Offline
    Ahmad Rifai Yusuf
    wrote on last edited by
    #1

    Hello everybody...! Anybody can tell me how should start TIMER from "00:00:00" ...? Thank you ...! :-D :-D :-D

    Best Regards, Ahmad Rifai Yusuf

    K L 3 Replies Last reply
    0
    • A Ahmad Rifai Yusuf

      Hello everybody...! Anybody can tell me how should start TIMER from "00:00:00" ...? Thank you ...! :-D :-D :-D

      Best Regards, Ahmad Rifai Yusuf

      K Offline
      K Offline
      Kevin Brydon
      wrote on last edited by
      #2

      Go read MSDN. Search Google. Have you tried any of these? No? Heres a hint http://msdn2.microsoft.com/en-us/library/system.timers.timer(VS.71).aspx[^]

      1 Reply Last reply
      0
      • A Ahmad Rifai Yusuf

        Hello everybody...! Anybody can tell me how should start TIMER from "00:00:00" ...? Thank you ...! :-D :-D :-D

        Best Regards, Ahmad Rifai Yusuf

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Test this code Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ' supposing we have a label and it has the text 00:00:00 when the form loads ' Timer interval we can set as per requirement ' I have set it for 0-9. If you want to test upto 1 minute then change 9 by 99 and 10 by 100 s = Label1.Text.Split(":") If CInt(s(2)) >= 0 AndAlso CInt(s(2)) < 9 Then s(2) = Format(CInt(s(2)) + 1, "00") ElseIf CInt(s(2)) = 9 Then s(2) = Format(0, "00") s(1) = CInt(s(1)) + 1 s(1) = Format(CInt(s(1)), "00") End If If CInt(s(1)) = 10 Then s(0) = Format(CInt(s(0)) + 1, "00") s(1) = Format(0, "00") End If Label1.Text = s(0) & ":" & s(1) & ":" & s(2) End Sub Hope this solves the purpose.

        J 1 Reply Last reply
        0
        • A Ahmad Rifai Yusuf

          Hello everybody...! Anybody can tell me how should start TIMER from "00:00:00" ...? Thank you ...! :-D :-D :-D

          Best Regards, Ahmad Rifai Yusuf

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I just forgot to mention one thing. Declare an string array globally like: Dim s() as String Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ' supposing we have a label and it has the text 00:00:00 when the form loads ' Timer interval we can set as per requirement ' I have set it for 0-9. If you want to test upto 1 minute then change 9 by 99 and 10 by 100 s = Label1.Text.Split(":") If CInt(s(2)) >= 0 AndAlso CInt(s(2)) < 9 Then s(2) = Format(CInt(s(2)) + 1, "00") ElseIf CInt(s(2)) = 9 Then s(2) = Format(0, "00") s(1) = CInt(s(1)) + 1 s(1) = Format(CInt(s(1)), "00") End If If CInt(s(1)) = 10 Then s(0) = Format(CInt(s(0)) + 1, "00") s(1) = Format(0, "00") End If Label1.Text = s(0) & ":" & s(1) & ":" & s(2) End Sub Hope this solves the purpose.

          D 1 Reply Last reply
          0
          • L Lost User

            Test this code Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ' supposing we have a label and it has the text 00:00:00 when the form loads ' Timer interval we can set as per requirement ' I have set it for 0-9. If you want to test upto 1 minute then change 9 by 99 and 10 by 100 s = Label1.Text.Split(":") If CInt(s(2)) >= 0 AndAlso CInt(s(2)) < 9 Then s(2) = Format(CInt(s(2)) + 1, "00") ElseIf CInt(s(2)) = 9 Then s(2) = Format(0, "00") s(1) = CInt(s(1)) + 1 s(1) = Format(CInt(s(1)), "00") End If If CInt(s(1)) = 10 Then s(0) = Format(CInt(s(0)) + 1, "00") s(1) = Format(0, "00") End If Label1.Text = s(0) & ":" & s(1) & ":" & s(2) End Sub Hope this solves the purpose.

            J Offline
            J Offline
            jchigg2000
            wrote on last edited by
            #5

            LOL! This is awesome advice!!!

            1 Reply Last reply
            0
            • L Lost User

              I just forgot to mention one thing. Declare an string array globally like: Dim s() as String Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ' supposing we have a label and it has the text 00:00:00 when the form loads ' Timer interval we can set as per requirement ' I have set it for 0-9. If you want to test upto 1 minute then change 9 by 99 and 10 by 100 s = Label1.Text.Split(":") If CInt(s(2)) >= 0 AndAlso CInt(s(2)) < 9 Then s(2) = Format(CInt(s(2)) + 1, "00") ElseIf CInt(s(2)) = 9 Then s(2) = Format(0, "00") s(1) = CInt(s(1)) + 1 s(1) = Format(CInt(s(1)), "00") End If If CInt(s(1)) = 10 Then s(0) = Format(CInt(s(0)) + 1, "00") s(1) = Format(0, "00") End If Label1.Text = s(0) & ":" & s(1) & ":" & s(2) End Sub Hope this solves the purpose.

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

              Wow, this is pretty bad. A value of time like this would normally be represented in your code by a TimeSpan object. You can then increment this time by adding 1 second to it on each tick of a 1000 millisecond timer. Your code can then be replaced by a very simple, single line of code:

              Label1.Text = myTimeSpan.ToString()
              

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              M 1 Reply Last reply
              0
              • D Dave Kreskowiak

                Wow, this is pretty bad. A value of time like this would normally be represented in your code by a TimeSpan object. You can then increment this time by adding 1 second to it on each tick of a 1000 millisecond timer. Your code can then be replaced by a very simple, single line of code:

                Label1.Text = myTimeSpan.ToString()
                

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #7

                Dave Kreskowiak wrote:

                Wow, this is pretty bad

                Masterful understatement, such restraint.

                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