-1

I have this code:

        Dim count As TimeSpan = TimeSpan.Zero
        For i = 0 To Lsv1.Items.Count - 1

            count.Add(TimeSpan.Parse(Lsv1.Items(i).SubItems(3).Text))
        Next
        textbox1.text = count.ToString("hh:mm:ss")

I keep getting this error: System.FormatException: 'Input string was not in a correct format.' Any assistance to count the time values in a listview

Jj84
  • 17
  • 7
  • FYI I googled `"Input string was not in a correct format" timespan` and the first result was a stackoverflow question asking the same thing with an answer that explained why it was happening and how to fix it. – Marie Nov 22 '19 at 14:45

1 Answers1

1

This should work. There was also another bug here. You have to set 'count' like this, or else you will get "00:00:00"

        Dim count As TimeSpan = TimeSpan.Zero
        For Each itm In Lsv1.Items    
            count += (TimeSpan.Parse(itm.SubItems(3).Text))
        Next
        textbox1.text = count.ToString("hh\:mm\:ss")
Brokdel
  • 41
  • 3