Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Using timespan get the string to subtract listview sub item

Visual Studio timer string

  • Please log in to reply
1 reply to this topic

#1 CodeWarrior


    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Programming Language:Visual Basic .NET
  • Learning:C#, (Visual) Basic, Python, Visual Basic .NET

Posted 09 August 2012 - 05:26 AM

Hey guys is there any one can help me about this code? I want to Subtract
the value of Listview SubsItem if the String Format in time span got 59
it will automatically subtract 1 for subitem tag

Private TimeLaps As Date
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim remainingTime As TimeSpan
For Each itm As ListViewItem In ListView1.Items

If CDate(itm.Tag) > Date.Now Then

remainingTime = CDate(itm.Tag).Subtract(Date.Now)

itm.SubItems(1).Text = String.Format("{0:d2}:{1:d2}:{2:d2}", _
remainingTime.Hours, _
remainingTime.Minutes, _

If itm.Tag(String.Format("{2:d2}").ToString = 59) Then ' <======== This part is the error
itm.SubItems(2).Tag = -1 '<=== and this part of code i want to subtract the text inside of the subitem(2) is
'the total minutes of timespan running.. if the timespan seconds string is 59
'then it will auto deducted the remaining minutes sample 60 minute then deduct 1
'so then remaining minutes left is 59

End If

End If

End Sub

  • 0

#2 kernelcoder


    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 09 August 2012 - 09:51 PM

What is the 'View' mode of your ListView? Details?

Why you are using Tag property of listview item and subitem? Did you assign the DateTime to Tag property of ListView items elsewhere in the code?

Show us the details about your code.
  • 0

Also tagged with one or more of these keywords: Visual Studio, timer, string

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download