Dim File2() As Byte File2() = Inet1.OpenURL("http://www.ajile.com/images/SP.jpg", icByteArray) ' Download file Open "i:\1.jpg" For Binary Access Write As #1 ' Choose local path Put #1, , File2() Close #1
1.添加部件Microsoft Internet Transfer Control 2.Dim File2() As Byte File2() = Inet1.OpenURL("http://www.ajile.com/images/SP.jpg", icByteArray) ' Download file Open "i:\1.jpg" For Binary Access Write As #1 ' Choose local path Put #1, , File2() Close #1
MSDN的FTP例子,HTTP例子很容易修改。 Private Sub cmdGET_Click() Inet1.Execute txtURL.Text, _ "GET GetThis.txt C:\MyDocuments\GotThis.txt" End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer) 'State = 12 时,用 GetChunk 方法检索服务器的响应。 Dim vtData As Variant ' Data variable. Select Case State '...没有列举其它情况。 Case icError '11 '出现错误时,返回 ResponseCode 和 ResponseInfo。 vtData = Inet1.ResponseCode & ":" & _ Inet1.ResponseInfo Case icResponseCompleted ' 12
Dim vtData As Variant Dim strData As String Dim bDone As Boolean: bDone = False '取得第一个块。 vtData = Inet1.GetChunk(1024, icString) DoEvents Do While Not bDone strData = strData & vtData '取得下一个块。 vtData = Inet1.GetChunk(1024, icString) DoEvents If Len(vtData) = 0 Then bDone = True End If Loop txtData.Text = strData End Select End Sub 其他代码我没有。没时间写。
File2() = Inet1.OpenURL("http://www.ajile.com/images/SP.jpg", icByteArray) ' Download file
Open "i:\1.jpg" For Binary Access Write As #1 ' Choose local path
Put #1, , File2()
Close #1
2.Dim File2() As Byte
File2() = Inet1.OpenURL("http://www.ajile.com/images/SP.jpg", icByteArray) ' Download file
Open "i:\1.jpg" For Binary Access Write As #1 ' Choose local path
Put #1, , File2()
Close #1
Private Sub cmdGET_Click()
Inet1.Execute txtURL.Text, _
"GET GetThis.txt C:\MyDocuments\GotThis.txt"
End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
'State = 12 时,用 GetChunk 方法检索服务器的响应。 Dim vtData As Variant ' Data variable.
Select Case State
'...没有列举其它情况。
Case icError '11
'出现错误时,返回 ResponseCode 和 ResponseInfo。
vtData = Inet1.ResponseCode & ":" & _
Inet1.ResponseInfo
Case icResponseCompleted ' 12
Dim vtData As Variant
Dim strData As String
Dim bDone As Boolean: bDone = False '取得第一个块。
vtData = Inet1.GetChunk(1024, icString)
DoEvents Do While Not bDone
strData = strData & vtData
'取得下一个块。
vtData = Inet1.GetChunk(1024, icString)
DoEvents If Len(vtData) = 0 Then
bDone = True
End If
Loop
txtData.Text = strData
End Select
End Sub
其他代码我没有。没时间写。