Hello,
Thank you for your question.
The VB6 Fill Form demo has some code that does what you're asking.
Let me copy & paste the relevant details.
Following is the content of the "Change Html" button Click method:
Code:
Private Sub ChangeHtmlButton_Click()
Dim Html As String
' change the html of an input textbox into a select (drop down)
InfoText.Text = "Changing the login name input textbox into a dropdown"
Html = "<select name=""username"">" & vbCrLf
Html = Html & " <option value=""Sylvia"">Sylvia</option>" & vbCrLf
Html = Html & " <option value=""Johnson"">Johnson</option>" & vbCrLf
Html = Html & " <option value=""Romeo"">Romeo</option>" & vbCrLf
Html = Html & " <option value=""Mario"">Mario</option>" & vbCrLf
Html = Html & " <option value=""Mr. Smith"">Mr. Smith</option>" & vbCrLf
Html = Html & " <option value=""Liza"">Liza</option>" & vbCrLf
Html = Html & "</select>" & vbCrLf
Document.SetElementOuterHtmlByName "username", Html
End Sub
This changes the existing html text control into a drop down.
Clicking on that button will show you that it actually replaces that text control with the html of a dropdown and it shows the list as below:
If you then click on the "Fill Form" button, it will select the "Mr Smith" option from the list.
The code of the Fill Form button click event looks like this:
Code:
Private Sub FillFormButton_Click()
Document.ElementValueByName("username") = "Mr. Smith"
Document.ElementValueByName("password") = "supersecret"
Document.ElementValueByName("your-none-existing-input") = "smith@example.com"
Document.SetInputCheckboxByName "remember", True
InfoText.Text = "Next Click the Read Form button."
End Sub
Hope this helps,
Wil
PS: I will be moving this thread to the AntView section in a bit.
Edit: See this help page, for a walk-through of this particular example:
VB6 - Fill Form Example