Hi ive been trying hard to get a img url collection from a textbox.. or how to stop loop on 3rd img url
please help me. Thank You.. Heres What ive Got.. URL: https://www.facebook.com/tony.trujillo.3517

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim PageElement As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName(TextBox1.Text)

        For Each CurElement As HtmlElement In PageElement


            TextBox2.Text = TextBox2.Text + CurElement.GetAttribute(TextBox3.Text) + Environment.NewLine


        Next

Recommended Answers

All 5 Replies

In your for loop there is no way to stop it before finishing. You can make a If ElseIf control flow. If it does not satisfy your condition exit from the loop.

A conditional that checks the size of the Lines property of the textbox should work

Dim PageElement As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName(TextBox1.Text)
For Each CurElement As HtmlElement In PageElement
    TextBox2.Text = TextBox2.Text + CurElement.GetAttribute(TextBox3.Text) + Environment.NewLine
    If TextBox2.Lines.Length = 3 Then
        Exit For
    End If
Next
commented: Excellent +0

Thank you so much, your method worked perfect.. Excellect!!

Please remember to mark the post solved if your question is answered. Thank You

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.