I have this code.

I need to loop through it, until button 2 is pressed.

I also want to count how many times its looped and show how many times in a label.

Public Class Form1



    

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("www.WEBSITEHERE.COM")
    End Sub

    Private Function GetPromotionElements() As HtmlElement()
        Dim inputElements As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
        Dim promotionElements As New List(Of HtmlElement)()

        For Each element As HtmlElement In inputElements
            Dim type As String = element.GetAttribute("type")
            Dim name As String = element.GetAttribute("name")

            If Not String.IsNullOrEmpty(type) AndAlso type = "checkbox" Then
                If Not String.IsNullOrEmpty(name) AndAlso name = "anonymous" Then
                    promotionElements.Add(element)
                End If
            End If
        Next
        Return promotionElements.ToArray()
    End Function


    Private Sub tickbox()
        Dim promotionElements() As HtmlElement = GetPromotionElements()

        For Each element As HtmlElement In promotionElements

            element.SetAttribute("checked", "false")
        Next

    End Sub

    Private Sub Submit()
        Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("button")
        For Each curElement As HtmlElement In theElementCollection
            Dim controlName As String = curElement.GetAttribute("name").ToString
            controlName = "Submit"
            curElement.InvokeMember("click")
        Next
        WebBrowser1.Refresh()
    End Sub




    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       
        tickbox()
        Submit()

    End Sub



End Class

Can anyone help me? Loop button1.

Member Avatar for Unhnd_Exception

You need to be more specific.

You have 3 procedures with For statements.

Explain a little more and it will get answered.

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.