代码如下:Dim LastTextBox As TextBox
Dim Inet1 As New Inet
Dim TotalLength As Long
Dim Step As SinglePrivate Sub Command1_Click()
'Inet1.Cancelxxx = Inet1.OpenURL("www.lawyee.net")
MsgBox xxx'Dim File() As Byte
' File() = INET1.OpenURL(Text1.Text, icByteArray)
'' Call Inet1_StateChanged
' Open "C:\1.zip" For Binary Access Write As #1
'' Put #1, , File()
' Close #1
' MsgBox "Success"
End SubPrivate Sub Form_Load()
Text1.Text = "http://www.lawyee.net/other/case20/2006080201.zpk"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData() As Byte '数据变量。
Dim Count As Long
MsgBox "222"
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
我点了Private Sub Command1_Click()后怎么没触发Inet1_StateChanged过程啊?
小弟对Inet不熟悉,
还有,我这个程序打算用来每天定时下载文件用的,如何在闲时释放inet?
我这样声明inet有问题吗?磕头了
Dim Inet1 As New Inet
Dim TotalLength As Long
Dim Step As SinglePrivate Sub Command1_Click()
'Inet1.Cancelxxx = Inet1.OpenURL("www.lawyee.net")
MsgBox xxx'Dim File() As Byte
' File() = INET1.OpenURL(Text1.Text, icByteArray)
'' Call Inet1_StateChanged
' Open "C:\1.zip" For Binary Access Write As #1
'' Put #1, , File()
' Close #1
' MsgBox "Success"
End SubPrivate Sub Form_Load()
Text1.Text = "http://www.lawyee.net/other/case20/2006080201.zpk"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData() As Byte '数据变量。
Dim Count As Long
MsgBox "222"
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
我点了Private Sub Command1_Click()后怎么没触发Inet1_StateChanged过程啊?
小弟对Inet不熟悉,
还有,我这个程序打算用来每天定时下载文件用的,如何在闲时释放inet?
我这样声明inet有问题吗?磕头了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货