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

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
Comments
Excellent
This question has already been answered. Start a new discussion instead.