Explanation:
Sample of a structure (old way):
Code: Select all
Structure ClientStruct
ClientID As String(21)
IPAddress As String(17)
PortNumber As String(7)
LastConnectDate As String(18)
Reserved(35) As Byte
End Structure
Code: Select all
Dim cs1, cs2 as ClientStruct
cs2.ClientID = cs1.ClientID
cs2.IPAddress = cs1.IPAddress
...
...
1) Add a byte array to the structure together with the "union" keyword in the structure (with the array length equal to the actual size of structure), and
2) Use a loop to copy the structure (see Sub copyStruct).
Sample of a structure (new way):
Code: Select all
Structure ClientStruct
ClientID As String(21)
IPAddress As String(17)
PortNumber As String(7)
LastConnectDate As String(18)
Reserved(35) As Byte
byteArray(98) As Byte Union
End Structure
Sub copyStruct(ByRef src as clientStruct, ByRef dst as ClientStruct)
Dim i as byte
for i = 0 to bound(src.bytearray)
dst.bytearray(i) = src.bytearray(i)
next
end sub