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. How to add clock timer to listview column in vb6?

How to add clock timer to listview column in vb6?

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
15 Posts 2 Posters 2 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.
  • N nlarson11

    vb6 - format(now,"hh:nn:ss") vb.net - now.tostring("hh:mm:ss")

    M Offline
    M Offline
    method007
    wrote on last edited by
    #5

    Thanks for you reply. I tried the following and it only display the current time!! I wanted to start from 00:00:00 and start running ListView1.ListItems(1).ListSubItems(4).Text = Format(Now, "hh:nn:ss")

    N 1 Reply Last reply
    0
    • M method007

      Thanks for you reply. I tried the following and it only display the current time!! I wanted to start from 00:00:00 and start running ListView1.ListItems(1).ListSubItems(4).Text = Format(Now, "hh:nn:ss")

      N Offline
      N Offline
      nlarson11
      wrote on last edited by
      #6

      make a module level variable that will hold to the current ticks private mStartDate As Double = Now.Ticks in the timer event routine Dim s As String = TimeSpan.FromTicks(Now.Ticks - mStartDate).ToString ListView1.ListItems(1).ListSubItems(4).Text = s.Substring(0, s.IndexOf("."))

      M 1 Reply Last reply
      0
      • N nlarson11

        make a module level variable that will hold to the current ticks private mStartDate As Double = Now.Ticks in the timer event routine Dim s As String = TimeSpan.FromTicks(Now.Ticks - mStartDate).ToString ListView1.ListItems(1).ListSubItems(4).Text = s.Substring(0, s.IndexOf("."))

        M Offline
        M Offline
        method007
        wrote on last edited by
        #7

        I placed "private mStartDate As Double = Now.Ticks: inside a module. Then i added timer to the form an set its interval to 1000.Then i added following code: Private Sub Form_Load() Timer2.Interval = 1000 ' <-- 10 seconds Timer2.Enabled = True End Sub Private Sub Timer2_Timer() Static lngMin As Long lngMin = lngMin + 1 'every 2nd timer tick reload the listview If lngMin Mod 2 Then Dim s As String = TimeSpan.FromTicks(Now.Ticks - mStartDate).ToString ListView1.ListItems(1).ListSubItems(4).Text = s.Substring(0, s.IndexOf(".")) End If End Sub then i get compile error : Expected: end of statement pointing at: private mStartDate As Double = Now.Ticks

        N 1 Reply Last reply
        0
        • M method007

          I placed "private mStartDate As Double = Now.Ticks: inside a module. Then i added timer to the form an set its interval to 1000.Then i added following code: Private Sub Form_Load() Timer2.Interval = 1000 ' <-- 10 seconds Timer2.Enabled = True End Sub Private Sub Timer2_Timer() Static lngMin As Long lngMin = lngMin + 1 'every 2nd timer tick reload the listview If lngMin Mod 2 Then Dim s As String = TimeSpan.FromTicks(Now.Ticks - mStartDate).ToString ListView1.ListItems(1).ListSubItems(4).Text = s.Substring(0, s.IndexOf(".")) End If End Sub then i get compile error : Expected: end of statement pointing at: private mStartDate As Double = Now.Ticks

          N Offline
          N Offline
          nlarson11
          wrote on last edited by
          #8

          this is vb6? i didn't think vb6 had listviews you can always create the time manually but I'll try to come up with vb6 equvilent...

          M 1 Reply Last reply
          0
          • N nlarson11

            this is vb6? i didn't think vb6 had listviews you can always create the time manually but I'll try to come up with vb6 equvilent...

            M Offline
            M Offline
            method007
            wrote on last edited by
            #9

            Many thanks for trying to help me:-). I am working on vb6 for this project. VB6 has listviews by selecting Microsoft windows common controls 6.0(sp6) component. I have seen a few applications not sure what programing language they are written it .They add timer to listview without noticing any flicker or reload!!

            N 1 Reply Last reply
            0
            • M method007

              Many thanks for trying to help me:-). I am working on vb6 for this project. VB6 has listviews by selecting Microsoft windows common controls 6.0(sp6) component. I have seen a few applications not sure what programing language they are written it .They add timer to listview without noticing any flicker or reload!!

              N Offline
              N Offline
              nlarson11
              wrote on last edited by
              #10

              ***make a module level variable*** private mStart as single ***in the load event of the form*** mStart = Timer ***in the timer event routine*** ListView1.ListItems(1).ListSubItems(4).Text = Format(TimeSerial(0, 0, cint(Timer - mStart), "hh:nn:ss") -- modified at 17:26 Friday 11th May, 2007

              M 1 Reply Last reply
              0
              • N nlarson11

                ***make a module level variable*** private mStart as single ***in the load event of the form*** mStart = Timer ***in the timer event routine*** ListView1.ListItems(1).ListSubItems(4).Text = Format(TimeSerial(0, 0, cint(Timer - mStart), "hh:nn:ss") -- modified at 17:26 Friday 11th May, 2007

                M Offline
                M Offline
                method007
                wrote on last edited by
                #11

                I tried it i get the following error: compile error: syntax error pointing at : ListView1.ListItems(1).ListSubItems(4).Text = Format(TimeSerial(0, 0, cint(Timer - mStart), "hh:nn:ss")

                N 1 Reply Last reply
                0
                • M method007

                  I tried it i get the following error: compile error: syntax error pointing at : ListView1.ListItems(1).ListSubItems(4).Text = Format(TimeSerial(0, 0, cint(Timer - mStart), "hh:nn:ss")

                  N Offline
                  N Offline
                  nlarson11
                  wrote on last edited by
                  #12

                  sorry...add a paren after the cint Format(TimeSerial(0, 0, cint(Timer - mStart)), "hh:nn:ss")

                  M 1 Reply Last reply
                  0
                  • N nlarson11

                    sorry...add a paren after the cint Format(TimeSerial(0, 0, cint(Timer - mStart)), "hh:nn:ss")

                    M Offline
                    M Offline
                    method007
                    wrote on last edited by
                    #13

                    Now i get this error in the same line: Run-time error 6: overflow

                    N 1 Reply Last reply
                    0
                    • M method007

                      Now i get this error in the same line: Run-time error 6: overflow

                      N Offline
                      N Offline
                      nlarson11
                      wrote on last edited by
                      #14

                      ok, use clng instead of cint

                      M 1 Reply Last reply
                      0
                      • N nlarson11

                        ok, use clng instead of cint

                        M Offline
                        M Offline
                        method007
                        wrote on last edited by
                        #15

                        same overflow error:-(( Private Sub Form_Load() mStart = Timer 'Set up the listview ListView1.View = lvwReport ListView1.ColumnHeaders.Add , , "Artist" ListView1.ColumnHeaders.Add , , "Name" ListView1.ColumnHeaders.Add , , "Image" ListView1.ColumnHeaders.Add , , "Rating" 'ListView1.ColumnHeaders.Add , , "Song ID" ListView1.ColumnHeaders.Add , , "Total Votes" ListView1.ColumnHeaders.Add , , "Page" ListView1.ColumnHeaders.Add , , "Referrer" ListView1.ColumnHeaders.Add , , "pageWindowName" Timer1.Interval = 1000 ' <-- 10 seconds Timer1.Enabled = True End Sub Private Sub Timer1_Timer() ListView1.ListItems(1).ListSubItems(4).Text = Format(TimeSerial(0, 0, CLng(Timer - mStart)), "hh:nn:ss") End Sub

                        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