Private Sub Command1_Click() Dim strURL As String, m_lDocSize As Long, strBuffer As String Dim lngArrivedDataSize As Long, strArrivedData As String strURL = "http://zhidao.baidu.com/question/68055519.html" Inet1.Execute strURL, "GET" '发出请求 Do While Inet1.StillExecuting '等待请求结束 DoEvents Loop If Len(Inet1.GetHeader("Content-Length")) > 0 Then '获取文件头信息 m_lDocSize = CLng(Inet1.GetHeader("Content-Length")) End If With ProgressBar1 '初始化进度条 .Max = m_lDocSize - Len(Inet1.GetHeader) .Min = 0 Do '开始获取数据 DoEvents strBuffer = Inet1.GetChunk(512) strArrivedData = strArrivedData & strBuffer lngArrivedDataSize = Len(strArrivedData) .Value = lngArrivedDataSize '进度显示 Loop Until Len(strBuffer) = 0 .Value = .Max End With Text1.Text = strArrivedData MsgBox "下载完毕!" End Sub
"GET Disclaimer.txt C:\Temp\Disclaimer.txt"
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)
http://feiyun0112.cnblogs.com/
Dim strURL As String, m_lDocSize As Long, strBuffer As String
Dim lngArrivedDataSize As Long, strArrivedData As String
strURL = "http://zhidao.baidu.com/question/68055519.html"
Inet1.Execute strURL, "GET" '发出请求
Do While Inet1.StillExecuting '等待请求结束
DoEvents
Loop
If Len(Inet1.GetHeader("Content-Length")) > 0 Then '获取文件头信息
m_lDocSize = CLng(Inet1.GetHeader("Content-Length"))
End If
With ProgressBar1 '初始化进度条
.Max = m_lDocSize - Len(Inet1.GetHeader)
.Min = 0
Do '开始获取数据
DoEvents
strBuffer = Inet1.GetChunk(512)
strArrivedData = strArrivedData & strBuffer
lngArrivedDataSize = Len(strArrivedData)
.Value = lngArrivedDataSize '进度显示
Loop Until Len(strBuffer) = 0
.Value = .Max
End With
Text1.Text = strArrivedData
MsgBox "下载完毕!"
End Sub