Get WebBrowser Control to Check Radio Option

Viewed 37

I want my vb6 program to check radio option and submit it through a PHP page. I have the following code:

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
   If WebBrowser1.LocationURL = "http://xx.xxxxxxxxxx.com/vb6.php" Then
      WebBrowser1.Document.frmC.cid.Value = "52821558"
      WebBrowser1.Document.frmC.instrument.Value = "CL"
      'WebBrowser1.Document.frmC.ctype
      WebBrowser1.Document.frmC.Submit.Click
   End If
End Sub

"ctype" in the code above represents the name of the radio option and bellow its HTML code

<INPUT TYPE="Radio" Name="ctype" value="Buy"><span style="font-size: 14px">Buy</span>
<INPUT TYPE="Radio" Name="ctype" value="Sell"><span style="font-size: 14px">Sell</span>
1 Answers

Use SetAttribute:

Dim radio As Object
Set radio = WebBrowser1.Document.frmC.ctype.Item(0)
radio.SetAttribute "checked", "checked"

Use .Item(0) for the first radio & .Item(1) for the second.

Related