VB creates automatic web page filling (highly recommended)
VB simple simulator tutorial Quick Start Edition
First, we will show you how to use vbprogramming to open a webpage:
As it paves the way for a simulator, we will not introduce other methods. We will only introduce one of the simplest ways to implement the webbrowser control (I have not learned other methods ).
Next we will begin to step into the gate of the simulator:
1. Open VB to create a project
2. Right-click the tool bar and select a part (I use the Chinese VB) or select a project menu and click a part.
3. Find Microsoft Internet controls and pick it up. Then, confirm that a Earth-like icon is displayed on the toolbar. Our subsequent implementations will be centered around it.
4. Add a webbrowser1 to form1, and then add a command1 to form1.
5. Add the following in form1:Code:
'---------- Start -----------
Private sub commandementclick ()
Webbrowser1.navigate "25emuhome.w.ubbs.com"
End sub
Private sub form_load ()
Webbrowser1.navigate "<a href = 'HTTP: // net2sky.yeah.net "/'
Target = _ blank> [url] http://net2sky.yeah.net [/url] ";
End sub
'---------- End -----------
6. Of course, it is a test. Click the "run" button. We can see that our webbrowser opens the home page of people on the network, and then click the button, our lovely webbrowser brought us to the simulation home BBS.
Well, let's write so much. Next time, let's take a look at how to use webbrowser to submit a webpage with a user name and password.
VB simple simulator tutorial entry edition (2)
2. How to Use the webbrowser of VB to submit a webpage containing a user name and password
The last time we learned how to open a Web page, today we will look at how to make money first.
Next we will start the step:
1. Open VB to create a project
2. Right-click the tool bar and select a part (I use the Chinese VB) or select a project menu and click a part.
3. Find Microsoft Internet controls and pick it up. Then, confirm that a Earth-like icon is displayed on the toolbar. Our subsequent implementations will be centered around it.
4. Add a webbrowser1 to form1, and then add a command1 to form1.
5. Add the following code to form1: (the above Code is described in the previous lecture. You should be familiar with it)
'---------- Start -----------
Private sub commandementclick ()
Dim vdoc, vtag
Dim I as integer
Set vdoc = webbrowser1.document
For I = 0 to vdoc. All. Length-1 'Check all labels
If ucase (vdoc. All (I). tagname) = "input" then' find the input tag
Set vtag = vdoc. All (I)
If vtag. type = "text" or vtag. type = "password" then', see if we need it.
Select case vtag. name' according to the name of the tag
Case "emailadd"
Vtag. value = "[email] myemail@home.com [/Email]" 'Write your e-mail here
Case "passwd"
Vtag. value = "password" 'write your password here
End select
Elseif vtag. type = "Submit" and vtag. Name = "sub" and vtag. value = "subscribe" then
'Find the submit button
Vtag. select' does not have this
Vtag. click' click Submit. Everything is OK.
End if
End if
Next I
End sub
Private sub form_load ()
Webbrowser1.navigate "http://dhunter.51.net"
End sub
'---------- End -----------
6. Of course, it is a test. Click the run button. We can see that our webbrowser is opened.
[Url] http://dhunter.51.net [/url], wait for the page to download the basic and then click the command1 button, our lovely webbrowser will
The email and password we just entered are submitted to the webpage. Have you seen the subscription successful? That is the sign of victory.
Well, let's write so much. Next time, let's take a look at how to use webbrowser to find a hyperlink in a webpage, which corresponds to a profitable connection.
Appendix (related materials ):
We can also see that this time we take the [url] http://dhunter.51.net [/url] on the subscription mail list to open the knife, below is the section of the web pageSource code:
<Form method = "Post" Action = "http://ml.xilu.com/cgi-bin/ml/client">
<P align = "center"> <font size = "2">
<Input type = "hidden" name = "userid" value = "dhunter">
E-mail:
<Input type = "text" name = "emailadd" value = "your e-mail">
<Br>
Password:
<Input type = "password" name = "passwd" value = "******">
<Br>
</Font> <font size = "2">
<Input type = "Submit" value = "subscribe" name = "sub">
<Input type = "Submit" value = "Unsubscribe" name = "unsub">
</Font> </P>
</Form>
All the labels with input in them accept the input. The main task of this talk is to find them and operate on them.
VB simple simulator tutorial Quick Start edition (3)
Third, how to use VB's webbrowser to find a hyperlink in a webpage
We have already talked about how to open a webpage and how to submit a webpage. Today, let's look at how to find URL and other elements in a webpage.
1. Open VB to create a project
2. Right-click the tool bar and select a part (I use the Chinese VB) or select a project menu and click a part.
3. Find Microsoft Internet controls and pick it up. Then confirm that a Earth-like icon is displayed on the toolbar, and our implementation is centered around it.
4. Add a webbrowser1 to form1, add a command1 to form1, and add a list1 to form1 (this list1 should be relaxed, in a moment, we will put all the qualified URLs in this directory)
5. Add the following code to form1: (the above Code is what we have mentioned before. You should be familiar with it)
'---------- Start -----------
Private sub commandementclick ()
Dim vtag, vdoc
Dim allcount, I
List1.clear
Set vdoc = webbrowser1.document. All
Allcount = vdoc. Length
For I = 0 to allcount-1
If ucase (vdoc. Item (I). tagname) = "A" then' find the URL
Vtag = vdoc. Item (I). href
If instr (vtag, "http://dhunter.51.net") then 'checks whether a URL contains a [url] http://dhunter.51.net [/url]
List1.additem vdoc. Item (I). href 'If yes, add it to list1
End if
End if
Next I
End sub
Private sub form_load ()
Webbrowser1.navigate "http://dhunter.51.net"
End sub
'---------- End -----------
6. Of course, it is a test. Click the run button. We can see that our webbrowser is opened.
[Url] http://dhunter.51.net [/url], wait for the page to download the basic and then click the command1 button, our lovely webbrowser will
All the URLs found that contain the [url] http://dhunter.51.net [/url] are added to list1.
With this, we can start to build our own simulators. Of course, more skills and more methods depend on you.