S
Stargate4004
Hi,
I have am converting a VB6 application to VB.net and have run into a
problem. The application connects to a TCP port on a Linux box and
receives a data buffer. The data buffer contains various fields, some
of which are two and four byte integers.
In VB6 I used the Mid function to pull data out of the buffer so I
could decrypt it (do all that tedius network-order byte-swapping, etc).
Quite simply, if I knew that the four bytes from position 42 in the
buffer contain a long integer I could:
myLong = DecryptLong(Mid(myDataBuffer, 42, 4))
However, in VB.net it seems that Mid will not always give me 4 bytes -
it terminates when it hits a chr(0). Thus I pass less than four bytes
into my DecryptLong function, and it gives the wrong result.
Is there any way to make Mid return everything I asked for, or any
function to pad the return string with chr(0)'s before I pass it to
DecryptLong? (I tried writing my own pad function but it suffered from
the same problem - VB.net just doesn't like nulls!)
Or is there a more effective way of extracting a substring than Mid,
one which perhaps gives you the substring you ask for?
Thanks.
I have am converting a VB6 application to VB.net and have run into a
problem. The application connects to a TCP port on a Linux box and
receives a data buffer. The data buffer contains various fields, some
of which are two and four byte integers.
In VB6 I used the Mid function to pull data out of the buffer so I
could decrypt it (do all that tedius network-order byte-swapping, etc).
Quite simply, if I knew that the four bytes from position 42 in the
buffer contain a long integer I could:
myLong = DecryptLong(Mid(myDataBuffer, 42, 4))
However, in VB.net it seems that Mid will not always give me 4 bytes -
it terminates when it hits a chr(0). Thus I pass less than four bytes
into my DecryptLong function, and it gives the wrong result.
Is there any way to make Mid return everything I asked for, or any
function to pad the return string with chr(0)'s before I pass it to
DecryptLong? (I tried writing my own pad function but it suffered from
the same problem - VB.net just doesn't like nulls!)
Or is there a more effective way of extracting a substring than Mid,
one which perhaps gives you the substring you ask for?
Thanks.