Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim PageInput As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each elem As HtmlElement In PageInput
If elem.GetAttribute("name") = "wdf_origin" Then
elem.SetAttribute("value", FromTXT.Text)
End If
If elem.GetAttribute("name") = "wdf_destination" Then
elem.SetAttribute("value", ToTXT.Text)
End If
If RadioButton1.Checked = True Then
elem.GetAttribute("id") = "oneway" Then
elem.SetAttribute("checked", RadioButton1.Checked) Then
elem.GetAttribute("id") = "wdfdate1" Then
elem.SetAttribute("value", DateTimePicker1.Text)
End If
If RadioButton2.Checked = True Then
elem.GetAttribute("id") = "return" Then
elem.SetAttribute("checked", RadioButton2.Checked) Then
elem.GetAttribute("id") = "wdfdate1" Then
elem.SetAttribute("value", DateTimePicker1.Text) Then
elem.GetAttribute("id") = "wdfdate2" Then
elem.SetAttribute("value", DateTimePicker2.Text)
End If
Next
Dim PageInput2 As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("select")
For Each elem As HtmlElement In PageInput2
If elem.GetAttribute("id") = "adults" Then
elem.SetAttribute("value", AdultsTXT.Text)
End If
If elem.GetAttribute("id") = "children" Then
elem.SetAttribute("value", ChildrenTXT.Text)
End If
If elem.GetAttribute("id") = "infants" Then
elem.SetAttribute("value", InfantsTXT.Text)
End If
If RadioButton1.Checked = True Then
elem.GetAttribute("id") = "wdftime1" Then
elem.SetAttribute("value", Time1TXT.Text)
End If
If RadioButton2.Checked = True Then
elem.GetAttribute("id") = "wdftime2" Then
elem.SetAttribute("value", Time2TXT.Text) Then
elem.GetAttribute("id") = "wdftime1" Then
elem.SetAttribute("value", Time1TXT.Text)
End If
Next
End Sub
At the moment, I am getting a this error
expression is a value and therefore cannot be the target of an assignment
on the elem.GetAttribute(" ") lines. Along with it saying it expects the statement to end on some of the Thens. Can I not set certain methods within if statements so that they include certain text boxes? I’m trying to get the RadioButtons to send certain text boxes depends on which RadioButton is selected.
Any suggestions or resources would be helpful.
You need to make sure that each Then has a coresponding If, also it looks like you actually need to be using the
AndAlsoandElseIfoperators to do what you are wanting. The reason that you are getting the “expression is a value and therefore cannot be the target of an assignment” errors are because you are trying to assign the value to your GetAttribute because of the lack of an If statement.See if this works better for you.