如果Winsock1_DataArrival(ByVal bytesTotal As Long),那么 bytesTotal 是从0还是1开始的?
答案:bytesTotal 是总体几个字节,比如1个字节。
如果你要做循环,就:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim i As Long
Dim arrB() As Byte
ReDim arrB(bytesTotal - 1)
Winsock1.GetData arrB
Dim b() As Byte
ReDim b(UBound(arrB))
For i = 0 To bytesTotal - 1
b(i) = arrB(i)
Next
'等价于下面
Dim c() As Byte
ReDim c(UBound(arrB))
For i = 0 To UBound(arrB)
c(i) = arrB(i)
Next
End Sub
结论:
UBound 是从0开始
bytesTotal 是从1开始