0

Hello there, I have this code:

If listItem.SubItems.Item(0).Text = " " Or listItem.SubItems.Item(0).Text = "" Then
   ListView1.Items.Remove(listItem)
End If

Now is it possible to make somehow to it actually count how much items got removed ? Want to show it example as:
'Clearing completed. XX Lines were removed.'

2
Contributors
1
Reply
9
Views
2 Years
Discussion Span
Last Post by Begginnerdev
1

Try declaring an integer value at the class level:

Dim iCount as Integer = 0

Then increment on removal:

If listItem.SubItems.Item(0).Text = " " Or listItem.SubItems.Item(0).Text = "" Then
    ListView1.Items.Remove(listItem)
    iCount += 1
End If

Once finished print out the count:

If iCount > 0 Then
    MsgBox("Clearing completed." & iCount & " Lines were removed.")
End If

Edited by Begginnerdev

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.