Some of the INET controls

xiaoxiao2021-03-06  41

Environment VB6 WinXP

Open VB6, new project

Add Parts Microsoft Internet Transfer Controls.

Add 2 buttons, 2 text boxes, and inet controls in Form

code show as below:

Option expedition

'This code uses GetHeader to return to page information, more accurate

'You can get the final modification date, file size, etc.

'Use this approach to judge whether a file exists

Private submmand1_click ()

Dim a as string

Dim Str As String

DIM RETCODE AS Long

Inet1.openurl "http://localhost/xml/tt.htm"

IF inet1.stillexecuting then

Doevents

END IF

'You can see all items

Msgbox inet1.getheader

'Get the date of modification is Green time, convert it Beijing time

Str = inet1.getheader ("last-modified")

Str = Replace (Right (STR (STR (STR) - INSTR (1, Str, ",") - 1), "GMT", ""

Text1.text = cdate (Format (Str, "YYYY / MM / DD HH: MM: SS")))))

MSGBOX INET1.GetHeader ("Content-Length")

Retcode = VAL (MID (Trim (inet1.getheader), 10, 3))

SELECT CASE RETCODE

Case 200

Msgbox "success"

Case 404

Msgbox "No found"

Case Else

Msgbox "error"

End SELECT

End Sub

'This code is simple to determine if it is connected to the Internet.

'If you connect, get the web source code and save

Private sub fascist2_click ()

Inet1.cancel

IF LEN (inet1.openurl ("http://localhost/xml/tt.htm")) <> 0 THEN

MsgBox "has been connected"

Text2.text = inet1.openurl ("http://localhost/xml/tt.htm")

IF inet1.stillexecuting then

Doevents

END IF

'Save to the file

Open app.path & "/index.htm" for Output AS # 1

Print # 1, Text2.Text

Close # 1

Else

Msgbox "no connection"

END IF

End sub. The veteran of finding a list of websites, I think he is definitely in a certain website to find that the WSOCKEXPERT capture package is found to find that he is passed by http://data.alexa.com/data?cli= 10 & DAT = SNBA & URL = Website address This kind of VB is very simple to write such a tool first join the INET control. This is not displayed after execution, which is not displayed. If you want to put it, then private submmand1_click () Webstr = inet1.openurl "http://data.alexa.com/data?cli=10&dat=snba&url=" & text1.text) WebNum1 = instr (WebStr, "Popularity") WebNum1 = Instr (WebNum1, Webstr, "Text") 6 WebNum2 = INSTR (WebNum1, Webstr, "/>") - 1 Web1 = MID (WebNum2 - WebNum1)) Text2 = Web1 End Sub This will display 624891 in Text = "624891" in Text2. Tested in TEXT, I didn't have fault, I didn't write a dedicated, although I didn't look at it, but the function is also beautiful. I can beautify it ~ PS: indicates a few questions :) 1. ============================================================================================================================================================== ====================================================================================================================00 == : MSDN's instructions for synchronous asynchronous and asynchronous transmission OpenURL methods transmit data in synchronous mode. Here, the simultaneous refers to the transfer operations that cannot be performed before the transmission operation is not completed. Such data transmission must be done before performing other codes. The Execute method transmits data asynchronously. When the Execute method is called, the transfer operation is independent of other processes. Thus, after the Execute method is called, other code can be executed simultaneously while receiving data in the background. What does this mean for users of the Internet Transfer control? Simply put, use the OpenURL method to directly get the data stream (as described above), or directly in the TextBox control (if the data is text format). On the other hand, if data is acquired with an Execute method, you must monitor the connection status of the control with the StateChanged event. When the appropriate state is reached, the GetChunk method is called to obtain data from the buffer of the control. This is discussed in more detail below.

转载请注明原文地址:https://www.9cbs.com/read-76626.html

New Post(0)