Use of the INET control

Source: Internet
Author: User
Tags file size
The Inet control supports HTTP and FTP communication protocols. You can use this control to complete many functions.
Let's take an example.

Environment VB6 + WINXP
Open VB6 and create a project
Add part Microsoft Internet Transfer Controls.
Add 2 buttons, 2 text boxes, and Inet controls to form.
The code is as follows:

Option Explicit
'This code uses GetHeader to return page information, which is more accurate.
'Get the last file modification date, file size, and so on.
'This method can also be used to determine whether a file exists.
Private Sub commandementclick ()
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
'All projects are displayed.
MsgBox Inet1.GetHeader

'Get the modified date and time is green time, convert it to Beijing time
Str = Inet1.GetHeader ("Last-modified ")
Str = Replace (Right (str, Len (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 1, 200
MsgBox "successful"
Case 1, 404
MsgBox "not found"
Case Else
MsgBox "Error"
End Select
End Sub

'This code is used to determine whether the connection is established with the internet.
'If connection is established, get the webpage source code and save it
Private Sub Command2_Click ()
Inet1.Cancel
If Len (Inet1.OpenURL ("http: // localhost/xmlt.htm") <> 0 Then

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.