1,502
社区成员




Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Command1_Click()
Inet1.Execute "http://ask.koubei.com/question/1306083100901.html"
End Sub
Function BytesToBstr(ByRef arrBody() As Byte, ByVal CodeBase As String) As String
'无数据
If UBound(arrBody) = 0 Then
BytesToBstr = ""
Exit Function
End If
Dim objStream As New ADODB.Stream
objStream.Type = adTypeBinary
objStream.Mode = adModeReadWrite
objStream.Open
objStream.Write arrBody
objStream.Position = 0
objStream.Type = adTypeText
objStream.Charset = CodeBase
BytesToBstr = objStream.ReadText
objStream.Close
Set objStream = Nothing
End Function
Private Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 12
Dim arrBuffer() As Byte '累计接收的数据
Dim tmpBuffer() As Byte '单次GetChunk获得的数据
Dim recCount As Long '累计接收的字节数
Dim strRecText As String
tmpBuffer = Inet1.GetChunk(1024, icByteArray)
recCount = UBound(tmpBuffer)
Do
ReDim Preserve arrBuffer(recCount + UBound(tmpBuffer))
CopyMemory arrBuffer(recCount), tmpBuffer(0), UBound(tmpBuffer)
recCount = recCount + UBound(tmpBuffer)
tmpBuffer = Inet1.GetChunk(1024, icByteArray)
Loop Until UBound(tmpBuffer) < 0
strRecText = BytesToBstr(arrBuffer, "utf-8")
End Select
End Sub
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Command1_Click()
Inet1.Execute "http://ask.koubei.com/question/1306083100901.html"
End Sub
Function BytesToBstr(ByRef arrBody() As Byte, ByVal CodeBase As String) As String
'无数据
If UBound(arrBody) = 0 Then
BytesToBstr = ""
Exit Function
End If
Dim objStream As New ADODB.Stream
objStream.Type = adTypeBinary
objStream.Mode = adModeReadWrite
objStream.Open
objStream.Write arrBody
objStream.Position = 0
objStream.Type = adTypeText
objStream.Charset = CodeBase
BytesToBstr = objStream.ReadText
objStream.Close
Set objStream = Nothing
End Function
Private Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 12
Dim arrBuffer() As Byte '累计接收的数据
Dim tmpBuffer() As Byte '单次GetChunk获得的数据
Dim recCount As Long '累计接收的字节数
Dim strRecText As String
recCount = 0
tmpBuffer = Inet1.GetChunk(1024, icByteArray)
Do
ReDim Preserve arrBuffer(recCount + UBound(tmpBuffer))
CopyMemory arrBuffer(recCount), tmpBuffer(0), UBound(tmpBuffer)
recCount = recCount + UBound(tmpBuffer)
tmpBuffer = Inet1.GetChunk(1024, icByteArray)
Loop Until UBound(tmpBuffer) < 0
strRecText = BytesToBstr(arrBuffer, "utf-8")
End Select
End Sub