How to add clock timer to listview column in vb6?
-
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")
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("."))
-
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("."))
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 -
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 -
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...
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!!
-
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!!
***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
-
***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
-
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")
-
sorry...add a paren after the cint Format(TimeSerial(0, 0, cint(Timer - mStart)), "hh:nn:ss")
-
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