Some of the INET controls

xiaoxiao2021-03-06  71

The INET control supports both HTTP and FTP communication protocols. Many functions can be accomplished using this control.

We look at the example.

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.

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

New Post(0)