Converting C Float value into VB Single data type Help

G

Guest

I'm reading byte information from a C++ program via TCP sockets. At one time
I thought I came across away to convert C Float data type into a VB single
data type. I'm reading the C data type in bytes from the socket stream but
can't seem to convert it. Any help would be greatly appreciated. Here is my
data:

The actual values in the C++ application:
Node 1 LL40
- Position [46.778 - 19.034]

The byte values I'm reading from the C++ socket stream:
-----------Node---------------
(8) 1 Byte
(9) 0 Byte
-----------X Coord------------
This should = 46.778
(10) 172 Byte
(11) 28 Byte
(12) 59 Byte
(13) 66 Byte
-----------y coord------------
This should = 19.034
(14) 162 Byte
(15) 69 Byte
(16) 152 Byte
(17) 65 Byte
------------------------------
 
A

Armin Zingler

Sisnaz said:
I'm reading byte information from a C++ program via TCP sockets. At
one time I thought I came across away to convert C Float data type
into a VB single data type. I'm reading the C data type in bytes
from the socket stream but can't seem to convert it. Any help would
be greatly appreciated. Here is my data:

The actual values in the C++ application:
Node 1 LL40
- Position [46.778 - 19.034]

The byte values I'm reading from the C++ socket stream:
-----------Node---------------
(8) 1 Byte
(9) 0 Byte
-----------X Coord------------
This should = 46.778
(10) 172 Byte
(11) 28 Byte
(12) 59 Byte
(13) 66 Byte
-----------y coord------------
This should = 19.034
(14) 162 Byte
(15) 69 Byte
(16) 152 Byte
(17) 65 Byte

If it's not possible to read the value as a Single value instead of an array
of bytes, use this:

dim s as single

s= bitconverter.ToSingle(yourByteArray, 10)



Armin
 
G

Guest

Thank you, thank you, thank you.... That did it!

Armin Zingler said:
Sisnaz said:
I'm reading byte information from a C++ program via TCP sockets. At
one time I thought I came across away to convert C Float data type
into a VB single data type. I'm reading the C data type in bytes
from the socket stream but can't seem to convert it. Any help would
be greatly appreciated. Here is my data:

The actual values in the C++ application:
Node 1 LL40
- Position [46.778 - 19.034]

The byte values I'm reading from the C++ socket stream:
-----------Node---------------
(8) 1 Byte
(9) 0 Byte
-----------X Coord------------
This should = 46.778
(10) 172 Byte
(11) 28 Byte
(12) 59 Byte
(13) 66 Byte
-----------y coord------------
This should = 19.034
(14) 162 Byte
(15) 69 Byte
(16) 152 Byte
(17) 65 Byte

If it's not possible to read the value as a Single value instead of an array
of bytes, use this:

dim s as single

s= bitconverter.ToSingle(yourByteArray, 10)



Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top