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.