Can somebody help me please to remove blank lines from listbox?
And remove specified text from listbox (text line that i can specify in form code(But if i specify to remove line something like "http://www.google.com/" it will remove the line "http://www.google.com/" but doesn't remove line "http://www.google.com/chrome/" etc ). Please help me somebody because i searched for hours in google, but can't find anything... Sorry for my english. I hope you understand what i want, because i'm a complete newbie with VB.

I use Microsoft Visual Studio 2008

My code for adding items to listbox is:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim PageElements As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("img")

        For Each CurElement As HtmlElement In PageElements

            ListBox1.Items.Add(CurElement.GetAttribute("src") & Environment.NewLine)


    End Sub

Cicle over the items and determine wich one is to be removed from the list.

Just as a hint, if you cicle from last to first, removing the item will not affect to the loop.

Dim ValueToSearchFor as String = "XYZ"

For I as Integer =  ListBox1.Items.count - 1 to 0 step -1
  If ListBox1.Items(I).Tostring.Trim.Length = 0 then
    If ListBox1.Items(I).Tostring.IndexOf(ValueToSearchFor)<>-1
    End If
  End If

Hope this helps

Thanks, i managed to make it work for me. :)

Edited 6 Years Ago by Mindazz: n/a

This question has already been answered. Start a new discussion instead.