Dim LastTextBox As TextBoxDim TotalLength As Long Dim Step As SinglePrivate Sub Command1_Click() Dim File() As Byte File() = Inet1.OpenURL(Text1.Text, icByteArray) Open "C:\1.zip" For Binary Access Write As #1 Put #1, , File() Close #1 MsgBox "Success" End SubPrivate Sub Command2_Click() Inet1.Execute Text1.Text, "GET" End SubPrivate Sub Form_Load() Text1.Text = "http://www14.brinkster.com/weblover/media2db.zip" End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer) Dim vtData() As Byte '数据变量。 Dim Count As Long Select Case State Case icHostResolvingHost Label1.Caption = "正在查询所指定的主机的 IP 地址" Case icHostResolved Label1.Caption = "成功地找到所指定的主机的 IP 地址" Case icConnecting Label1.Caption = "正在与主机连接" Case icConnected Label1.Caption = "已与主机连接成功" Case icRequesting Label1.Caption = "正在向主机发送请求" Case icRequestSent Label1.Caption = "发送请求已成功" Case icReceivingResponse Label1.Caption = "在接收主机的响应" Case icResponseReceived Label1.Caption = "成功地接收到主机的响应" Case icDisconnecting Label1.Caption = "正在解除与主机的连接" Case icDisconnected Label1.Caption = "已成功地与主机解除了连接" Case icError Label1.Caption = "与主机通讯时出现了错误" Case icResponseCompleted '12
TotalLength = Val(Inet1.GetHeader("Content-length")) Step = (Me.ScaleWidth - Picture1.Left * 2) / TotalLength Debug.Print Step Label1.Caption = "请求已经完成,并且所有数据均已接收到" Open "C:\1.zip" For Binary Access Write As #1 vtData = Inet1.GetChunk(1024, icByteArray) Count = 1000 Picture1.Width = Picture1.Width + Count * Step Label1.Caption = "" & Round(Count * 1000 / TotalLength, 0) & "%" 'Me.Refresh Do While UBound(vtData) > 0 Put #1, , vtData vtData = Inet1.GetChunk(1024, icByteArray) Picture1.Width = Picture1.Width + 1024 * Step Count = Count + 1024 Label2.Caption = "" & Round(Count * 100 / TotalLength, 0) & "%" Loop Put #1, , vtData Close #1 Label2.Caption = "100%" MsgBox "下载完成" End Select End Sub Top
? 搞定了,,,费了劲了给分吧! Dim LastTextBox As TextBoxDim TotalLength As Long Dim Step As SinglePrivate Sub Command1_Click() Dim File() As Byte File() = Inet1.OpenURL(Text1.Text, icByteArray) Open "C:\1.zip" For Binary Access Write As #1 Put #1, , File() Close #1 MsgBox "Success" End SubPrivate Sub Command2_Click() Inet1.Execute Text1.Text, "GET" End SubPrivate Sub Form_Load() Text1.Text = "http://www14.brinkster.com/weblover/media2db.zip" End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer) Dim vtData() As Byte '数据变量。 Dim Count As Long Select Case State Case icHostResolvingHost Label1.Caption = "正在查询所指定的主机的 IP 地址" Case icHostResolved Label1.Caption = "成功地找到所指定的主机的 IP 地址" Case icConnecting Label1.Caption = "正在与主机连接" Case icConnected Label1.Caption = "已与主机连接成功" Case icRequesting Label1.Caption = "正在向主机发送请求" Case icRequestSent Label1.Caption = "发送请求已成功" Case icReceivingResponse Label1.Caption = "在接收主机的响应" Case icResponseReceived Label1.Caption = "成功地接收到主机的响应" Case icDisconnecting Label1.Caption = "正在解除与主机的连接" Case icDisconnected Label1.Caption = "已成功地与主机解除了连接" Case icError Label1.Caption = "与主机通讯时出现了错误" Case icResponseCompleted '12
TotalLength = Val(Inet1.GetHeader("Content-length")) Step = (Me.ScaleWidth - Picture1.Left * 2) / TotalLength Debug.Print Step Label1.Caption = "请求已经完成,并且所有数据均已接收到" Open "C:\1.zip" For Binary Access Write As #1 vtData = Inet1.GetChunk(1024, icByteArray) Count = 1000 Picture1.Width = Picture1.Width + Count * Step Label1.Caption = "" & Round(Count * 1000 / TotalLength, 0) & "%" 'Me.Refresh Do While UBound(vtData) > 0 Put #1, , vtData vtData = Inet1.GetChunk(1024, icByteArray) Picture1.Width = Picture1.Width + 1024 * Step Count = Count + 1024 Label2.Caption = "" & Round(Count * 100 / TotalLength, 0) & "%" Loop Put #1, , vtData Close #1 Label2.Caption = "100%" MsgBox "下载完成" End Select End Sub
Dim Step As SinglePrivate Sub Command1_Click()
Dim File() As Byte
File() = Inet1.OpenURL(Text1.Text, icByteArray)
Open "C:\1.zip" For Binary Access Write As #1
Put #1, , File()
Close #1
MsgBox "Success"
End SubPrivate Sub Command2_Click()
Inet1.Execute Text1.Text, "GET"
End SubPrivate Sub Form_Load()
Text1.Text = "http://www14.brinkster.com/weblover/media2db.zip"
End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData() As Byte '数据变量。
Dim Count As Long
Select Case State
Case icHostResolvingHost
Label1.Caption = "正在查询所指定的主机的 IP 地址"
Case icHostResolved
Label1.Caption = "成功地找到所指定的主机的 IP 地址"
Case icConnecting
Label1.Caption = "正在与主机连接"
Case icConnected
Label1.Caption = "已与主机连接成功"
Case icRequesting
Label1.Caption = "正在向主机发送请求"
Case icRequestSent
Label1.Caption = "发送请求已成功"
Case icReceivingResponse
Label1.Caption = "在接收主机的响应"
Case icResponseReceived
Label1.Caption = "成功地接收到主机的响应"
Case icDisconnecting
Label1.Caption = "正在解除与主机的连接"
Case icDisconnected
Label1.Caption = "已成功地与主机解除了连接"
Case icError
Label1.Caption = "与主机通讯时出现了错误"
Case icResponseCompleted '12
TotalLength = Val(Inet1.GetHeader("Content-length"))
Step = (Me.ScaleWidth - Picture1.Left * 2) / TotalLength
Debug.Print Step
Label1.Caption = "请求已经完成,并且所有数据均已接收到"
Open "C:\1.zip" For Binary Access Write As #1
vtData = Inet1.GetChunk(1024, icByteArray)
Count = 1000
Picture1.Width = Picture1.Width + Count * Step
Label1.Caption = "" & Round(Count * 1000 / TotalLength, 0) & "%"
'Me.Refresh
Do While UBound(vtData) > 0
Put #1, , vtData
vtData = Inet1.GetChunk(1024, icByteArray)
Picture1.Width = Picture1.Width + 1024 * Step
Count = Count + 1024
Label2.Caption = "" & Round(Count * 100 / TotalLength, 0) & "%"
Loop
Put #1, , vtData
Close #1
Label2.Caption = "100%"
MsgBox "下载完成"
End Select
End Sub
Top
回复人: minghao1039(明皓) ( ) 信誉:87 2002-07-11 16:45:11Z 得分:0
?
我靠~!~!
什么破论坛啊.
好多回了.
我辛苦回完了贴子.却回复的时候出现错误.
我还要重打啊???????????????????????????????????????????????
新技术新技术. 用的好些再拿出来也行啊~! K~~回复: 用 Inet 可以实现.原理无非是取得当前数据的大小.还有文件原来大小.
文件原来大小用 inet1.execute url,"size myfile.exe" 来取得.
当前数据大小. 用inet1.getchunk 方法,得到缓冲区的数据.再 len一下.
和原文件大小一坐对比. OK了.MD,还是先复制一遍.再发表.安全些.
Top
回复人: griefforyou(为你伤心) ( ) 信誉:110 2002-07-11 16:46:01Z 得分:0
?
搞定了,,,费了劲了给分吧!
Dim LastTextBox As TextBoxDim TotalLength As Long
Dim Step As SinglePrivate Sub Command1_Click()
Dim File() As Byte
File() = Inet1.OpenURL(Text1.Text, icByteArray)
Open "C:\1.zip" For Binary Access Write As #1
Put #1, , File()
Close #1
MsgBox "Success"
End SubPrivate Sub Command2_Click()
Inet1.Execute Text1.Text, "GET"
End SubPrivate Sub Form_Load()
Text1.Text = "http://www14.brinkster.com/weblover/media2db.zip"
End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData() As Byte '数据变量。
Dim Count As Long
Select Case State
Case icHostResolvingHost
Label1.Caption = "正在查询所指定的主机的 IP 地址"
Case icHostResolved
Label1.Caption = "成功地找到所指定的主机的 IP 地址"
Case icConnecting
Label1.Caption = "正在与主机连接"
Case icConnected
Label1.Caption = "已与主机连接成功"
Case icRequesting
Label1.Caption = "正在向主机发送请求"
Case icRequestSent
Label1.Caption = "发送请求已成功"
Case icReceivingResponse
Label1.Caption = "在接收主机的响应"
Case icResponseReceived
Label1.Caption = "成功地接收到主机的响应"
Case icDisconnecting
Label1.Caption = "正在解除与主机的连接"
Case icDisconnected
Label1.Caption = "已成功地与主机解除了连接"
Case icError
Label1.Caption = "与主机通讯时出现了错误"
Case icResponseCompleted '12
TotalLength = Val(Inet1.GetHeader("Content-length"))
Step = (Me.ScaleWidth - Picture1.Left * 2) / TotalLength
Debug.Print Step
Label1.Caption = "请求已经完成,并且所有数据均已接收到"
Open "C:\1.zip" For Binary Access Write As #1
vtData = Inet1.GetChunk(1024, icByteArray)
Count = 1000
Picture1.Width = Picture1.Width + Count * Step
Label1.Caption = "" & Round(Count * 1000 / TotalLength, 0) & "%"
'Me.Refresh
Do While UBound(vtData) > 0
Put #1, , vtData
vtData = Inet1.GetChunk(1024, icByteArray)
Picture1.Width = Picture1.Width + 1024 * Step
Count = Count + 1024
Label2.Caption = "" & Round(Count * 100 / TotalLength, 0) & "%"
Loop
Put #1, , vtData
Close #1
Label2.Caption = "100%"
MsgBox "下载完成"
End Select
End Sub