Fill and submit the input box on IE with VB

Source: Internet
Author: User

Fill and submit the input box on IE with VB
Assume that the HTML code of the logon page is as follows:

<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">

<HTML>
<Head>
<Title> testpage </title>
</Head>

<Body>

<Form name = chh method = "Post" Action = "login. asp">

<Table width = "100%" border = "0" cellspacing = "0" cellpadding = "2">
<Tr>
<TD width = "31%" align = "center"> User: </TD>
& Lt; TD width = "69%" align = "Left" & gt;
<Input name = "loginname" type = "text" id = "loginname" size = "12">
</TD>
</Tr>
<Tr>
<TD width = "31%" align = "center"> password: </TD>
& Lt; TD width = "69%" align = "Left" & gt;
<Input name = "loginpassword" type = "password" id = "loginpassword" size = "12">
</TD>
</Tr>
</Table>
<Input type = "Submit" id = "clickme" value = "Submit">
</Form>
</Body>
</Html>

On the simple page, there is a login form, a username input box loginname, a password input box loginpassword, and a submit button clickme.

 

Then open the page with IE. Note that the title of the page is set to testpage.

 

Open VB and reference Microsoft Internet controls in the project:

Private sub commandementclick ()
Dim ielist as new shellwindows
Dim Browser
Dim Doc

On Error resume next

'Traverse the current local browser window
For each browser in ielist
'Locate the required ie window
If browser. Document. Title = "testpage" then
'Get the file objects in the browser.
Set Doc = browser. Document

'Fill In the username field
Doc. Body. All ("loginname"). value = "Eddie"
'Fill in the password field
Doc. Body. All ("loginpassword"). value = "123456"

'Submit
Doc. Body. All ("clickme"). Click
End if
Next
End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.