Can I pass an array across a winsock connection? Every time I try I get the error "Unsupported Variant Type".
I must be missing something
Printable View
Can I pass an array across a winsock connection? Every time I try I get the error "Unsupported Variant Type".
I must be missing something
You have to convert it to one of VB's intrinsic data types. In this case, a byte array.
add the following to your code...
and then copy the array to a byte array.Code:Private Declare Sub CopyMemory Lib "KERNEL32" _
Alias "RtlMoveMemory" (hpvDest As Any, _
hpvSource As Any, _
ByVal cbCopy As Long)
i.e.
Lately, there have been a lot of posts on this topic. I have put together a small client/server example that passes a record back and forth. The record has the following structure:Code:Dim bTBuff() As Byte ' buffer for sends/receives
ReDim bTBuff(Len(theArray))
CopyMemory bTBuff(0), theArray, Len(theArray)
tcpServer.SendData bTBuff
There are enough comments in the code to explain (I hope) what is happening and what you have to do to send/receive complicated data structures in VB. If anyone is interested, contact me and I will send the project in a zipped file.Code:Private Type dclLogRec
UserId As String * 8
PassWd As String * 8
UserOK As Integer
End Type