Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) '当新数据到达时产生该事件
On Error Resume Next '在错误处理程序结束后,恢复原有的运行
Dim webData As String
Winsock1.GetData webData, vbString '检取当前的数据块
If InStr(1, webData, "Content-Length:") > 0 And FileSize = 0 Then '仅第一次计算,FileSize=0
Dim pos1 As Long, pos2 As Long
pos1 = InStr(1, webData, "Content-Length:")
pos2 = InStr(pos1 + 16, webData, vbCrLf)
If pos2 > pos1 Then
filesizebyte = Mid(webData, pos1 + 16, pos2 - pos1 - 16) '计算文件的长
MsgBox filesizebyte
'Winsock1.Close
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) '当新数据到达时产生该事件
On Error Resume Next '在错误处理程序结束后,恢复原有的运行
Dim webData As String
Winsock1.GetData webData, vbString '检取当前的数据块
If InStr(1, webData, "Content-Length:") > 0 And FileSize = 0 Then '仅第一次计算,FileSize=0
Dim pos1 As Long, pos2 As Long
pos1 = InStr(1, webData, "Content-Length:")
pos2 = InStr(pos1 + 16, webData, vbCrLf)
If pos2 > pos1 Then
filesizebyte = Mid(webData, pos1 + 16, pos2 - pos1 - 16) '计算文件的长
MsgBox filesizebyte'成功取得文件长度
End If
End If