# A sample for byte data convert .

Posted by °²±¦ on June 21, 1999 at 16:21:51:

In Reply to: Receive Byte array to change Decimal posted by ÍõÁ® on June 17, 1999 at 19:55:18:

For general conditions :
1. 2 bytes integer (Word) :
iValue = &H00 * DataByte(0) + DataByte(1)
2. 4 bytes integer (Long) :
iValue = &H000000 * DataByte(0) + &H0000 * DataByte(1) + &H00 * DataByte(2) +DataByte(3)
3. 4 bytes single (Real) or 4 bytes double (float) ???

Some machines have limited that you have to change the high - low bytes data . Here you need to try it .

May be you can use another method (We have tried it already ) :

' Here I will show you a sample for single data transferring . If
' you need , you can change the data type by yourself.

Public type iBuff
bFloat as single
end type

Public type iArr
bByte(3) as Byte
end type

Dim sBinData as iBuff
Dim sBytData as iArr
Dim nValue as single
For i = 0 To 3
sBytData.bByte(3 - i) = RecvByteData(i)
Next i
LSet sBinData = sBytData
nValue = sBinData.bFloat

Follow Ups: