Value of type 'System.Windows.Forms.ListViewItem.ListViewSubItem' can not be converted to 'Integer'
Basically, I need to total up a number column in a ListView.
Beantown Boy
Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
I did add the Text property to it originally, but that gave me an error.
Beantown Boy
Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
The Listview in .NET is 0-based (VB6 is 1-based), so if you have 53 items, then loop from 0 to 52. ListView1.Items.Count will return 53, which means you're looping from 0 to 53 and index 53 doesn't exist.
You don't have to do "intRptTotal = intRptTotal + ....", but you can do "intRptTotal += ..." instead.
vb.net Code:
Dim intRptTotal As Integer = 0
For i As Integer = 0 To lvwReportCount.Items.Count - 1
The Listview in .NET is 0-based (VB6 is 1-based), so if you have 53 items, then loop from 0 to 52. ListView1.Items.Count will return 53, which means you're looping from 0 to 53 and index 53 doesn't exist.
That is where I was going wrong...I was still using a 1-based loop. Thanks.
Originally Posted by Chris001
You don't have to do "intRptTotal = intRptTotal + ....", but you can do "intRptTotal += ..." instead.
I know I can do it that way, but I don't, and I won't.
I find it far more clear to use variable = variable + newvariable
Old dog...new tricks...etc.
Beantown Boy
Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.