(1) Inet is OpenURL way,
Dim (b) As Byte
Dim strURL As String
Dim fil As Integer
On Error GoTo Err1
Label3. Caption="is being downloaded,,,,,"
'the url screen
StrURL="http://www.kinglmm.com.cn/data/UserSer.DAT" "small files, download content is not correct
'strURL="ftp://www.kinglmm.com.cn/data/cod21.add", "large files, correct download
(b)=rc.inet1. OpenURL (strURL, icByteArray)
If UBound (b) & gt; 0 Then
Fil=FreeFile
Open "D: \ UserSer dat" For Binary Access Write As # fil
'Open "D: \ cod21. Add" For Binary Access Write As # fil
Put # fil, and (b)
Close # fil
Label3. Caption="download"
The Else
Label3. Caption="to"
End the If
The Exit Sub
Err1:
MsgBox "download data error"
(2) using the Get method of Inet is the same:
rc.inet1. URL="http://www.kinglmm.com.cn/data/UserSer.DAT"
'rc.inet1. URL="http://www.kinglmm.com.cn/data/cod21.ADD"
Rc.inet1. Execute, "Get"
Private Sub Inet1_StateChanged (ByVal State As an Integer)
Dim aa As the Variant
Dim vtData () As Byte 'data variables,
Dim iU As Long, I As an Integer, il As Integer
Dim TotalLength As the Variant
If the State=12 Then
TotalLength=Val (rc.inet1 GetHeader (" the Content - length "))
PsB. Max=TotalLength
'Open "d: \ CodeAdd bin" For Binary Access Write As # 1
'the Open "d: \ UserSer Dat" For Binary Access Write As # 1
'Open "d: \ Cod21 bin" For Binary Access Write As # 1
Open "d: \ the UserINfo. TXT" For Binary Access Write As # 1
VtData=https://bbs.csdn.net/topics/Inet1.GetChunk (1024, icByteArray)
The Do While UBound (vtData) & gt; 0
DoEvents
Put # 1, and vtData
If (PsB) Value + 1024) & gt; PsB. Max Then
PsB. Value=https://bbs.csdn.net/topics/PsB.Max
The Else
PsB. Value=https://bbs.csdn.net/topics/PsB.Value + 1024
End the If
VtData=https://bbs.csdn.net/topics/Inet1.GetChunk (1024, icByteArray)
Loop
Put # 1, and vtData
Close # 1
MsgBox "the download
"End the If
If the State=11 Then 'error
End the If
End Sub
Small file download didn't say wrong, but the file downloaded a 2 k, is not the file on the site, is an error message file, save it into a TXT file, display content is:
& lt; ! PUBLIC DOCTYPE HTML "- 4.01//////W3C DTD HTML EN" "http://www.w3.org/TR/html4/strict.dtd" & gt;
Cannot find the page & lt;/TITLE>
<meta HTTP - EQUIV="content-type" Content="text/HTML. Charset=GB2312 "& gt;
<style type="text/CSS" & gt;
BODY {9 pt/12 pt font: tahoma}
H1 {12 pt font: 15 pt/song typeface}
The H2 {9 pt/12 pt font: tahoma}
A: the link {color: red}
A: visited {color: maroon}
</style>
<body>
The page you are looking for might have been deleted, renamed or is temporarily unavailable.
Please try the following: & lt;/p>
- Ensure that the browser's address bar shown in the website address spelling and format is correct, & lt;/li>
- If you reached this page by clicking a link, please contact the site administrator and inform them of the link format is not correct,
- Click & lt; A href="javascript: history. The back (1)" & gt; Back & lt;/a> Button to try another link, & lt;/li>
Internet information services (IIS) & lt;/h2 & gt;
Technical information (for technical support personnel & lt;/p>
- Go to & lt; A href="http://go.microsoft.com/fwlink/? Linkid=8180 "& gt; Microsoft product support services & lt;/a> And search including & amp; other HTTP& Throughout; And & amp; other 404 & amp; Throughout; The title, & lt;/li>
- Open & amp; other IIS help & amp; Throughout; (access) in IIS manager (inetmgr), and then search the title for & amp; other Web site set up & amp; Throughout; , & amp; other Routine management tasks & amp; Throughout; And & amp; other About custom error messages & amp; Throughout; The theme of & lt;/li>