Originally, this part should also be placed in the second chapter, on the one hand, in order to be eye-catching, on the other hand, this method is actually a large connection and similarity to the Internet Explorer object, so it is specially placed behind the Internet Explorer object. Introduce.
Now what we have to use is also the "navigate" method of WebBrowser, whose function prototype is as follows:
Sub Navigate (URL AS String, [Flags], [TargetFramename], [POSTDATA], [Headers])
Everyone may wish to compare it with the "navigate" method of the Internet Explorer object in Chapter 3, exactly the same interface! !
Create a new project, check "Microsoft Internet Controls", add a webbrowser1, a command1 on the form, you can take WebBrowser1 appropriately, add the following code to Form1:
Private submmand1_click ()
Redim Abyte (0) as byte 'Array of Bytes to Hold Data To POST
CPOSTDATA = "login_name = Account & Password = Password & Cookietime = 0 & x = 42 & y = 10"
PackBytes Abyte (), CPostData
DIM VPOST As Variant
vpost = abyte 'assign the byte array to a variant
Dim vheaders as variant
Vheaders = "Content-Type: Application / X-WWW-FORM-URLENCODED" CHR (10) CHR (13)
WebBrowser1.navigate "http://www.9cbs.net/member/logon.asp",, vpost, vheaders
End Sub
Private sub packbytes (byteaRray () as Byte, byval postData as string
inewbytes = len (postdata) - 1 'get rid of the null termination
IF inewbytes <0 THEN
EXIT SUB
END IF
Redim ByteArray (inewbytes)
For i = 0 to inewbytes
CH = MID (PostData, i 1, 1)
IF ch = space (1) THEN
CH = " "
END IF
Debug.print CH, ASC (CH)
BYTEARRAY (I) = ASC (CH)
NEXT
End Sub
(Please refer to the code in Chapter 3.)
Through the introduction of these four articles, I think readers must not only have a deeper understanding of the VB login web server, and at the same time understand the HTTP protocol, cookie, and session also deepened!
Full text! ! !
Note: This series of articles, please do not use for commercial purposes, please contact me in advance, please contact me in advance.