The exception is telling you the problem:
Conversion from type Match
to type String
is not valid.
Look at what you're trying to do:
For Each item As String In ListBox1.Items
Clearly, ListBox1.Items
contains a collection of Match
objects, not a collection of String
objects. So you need to loop over those objects:
For Each item As Match In ListBox1.Items
Of course, we don't know what a Match
object is, since you haven't shown that. Presumably it contains a string somewhere, which you should be able to get from item
in your logic. But the point is that you can't implicitly convert one type to another, you have to use the correct type in your loop.