0

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
3
Contributors
5
Replies
37
Views
2 Years
Discussion Span
Last Post by tinstaafl
1

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.

1

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
Votes + Comments
Excellent
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.