Run a test for me..
Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim itemCount as Integer = 0
Try
For Each elem1 As HtmlElement In WebBrowser2.document.GetElementsByTagName("Scan")
itemCount +=1
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MessageBox.Show("Item Count: " & itemCount.ToString())
End Sub
How many items is it finding by the tag name "Scan"? If 0, then any code inside your FOREACH loop isn't getting run.
---------------------------------------------------------
Code:
For Each elem1 As HtmlElement In WebBrowser2.document.GetElementsByTagName("Scan")
WebBrowser2.document.GetElementById("remoteHost").SetAttribute("value", TextBox5.Text)
WebBrowser2.document.GetElementById("start_port").SetAttribute("value", TextBox6.Text)
WebBrowser2.document.GetElementById("end_port").SetAttribute("value", TextBox7.Text)
And surely you don't want that running inside a loop? No reason to set the attribute multiple times.
GetElementById() is good, but doesn't need to be inside a loop.