A1VBCode Forums

Converting Variables to byte arrays


http://www.a1vbcode.com/vbforums/Topic30407.aspx

By Perrie - 5/31/2011

Ive just discovered winsock doesnt like User Defined types so I figure it will be easier to convert the entire block of data into a byte array, send that and then convert back into its components in the type at the other end.

Bytes and strings are easy to do but I cant seem to find any reference as to how integers, long integers, singles and doubles are assembled except for how many bytes long they are.

I know that 1 bit is used to determine if the value is positive or negative but is it the most or least significant bit and in what order are the bytes stored to create the value.

By jacketsodaly - 1/16/2012

Dont worry I found a workaround for this one.



Create a second User Defined Type of a single byte array with more elements than any of the types I have created



Use Lset to push my defined type into the byte array



Use a loop to cycle the individual bytes out of the defined array into a normal Byte array



send that byte array through winsock



do same procedure in reverse at the recieving end

I agree with you, thanks!























-----------------------------------------------------------------------------------------------------------------

party dresses|flower girl dresses|trumpet wedding dresses