Hello everyone,

I am facing a problem with the following project:

in my project i have a Listbox with the Style = Checked,
The idea is to execute a task on every item in the List.

I wrote the following to delete each item found if Checked:

For X = 0 To List1.ListCount - 1
If List1.Selected(X) = True Then
List1.RemoveItem List1.ListIndex
End If
Next X

But an error occured, because each time the statement find
an item checked, the listcount get decreased by 1 everytime.

So far i have made only this to set attributes to many files at once.
This project doesn't have Style = Checked, this is normal.

Dim ctr As Integer
For ctr = 0 To List1.ListCount - 1
SetAttr List1.List(ctr), vbReadOnly
Next

And work very well, then i tried to use this same code to lock files,
But i could not, for some reason it only lock the first item but not
the rest of the items in the listbox.

I would like to use this same method to do just about anything when
dealing with a listbox in my project.

Here is another example:
I made a little project with a listbox, the idea was to check for some
Registry values, if found, they will be added to the listbox, the next
task was to delete those values or to change them all, depending on what
value for each value, but since they were to many, i did not know what to
add in the code:

Dim ctr As Integer
For ctr = 0 To List1.ListCount - 1
===> I meant here <===
Next

what is the appropriate code to do these three tasks?

Thank you all in advance