Hi.
Using redrocks solution, I have modified it for my specific purposes.
Under here the two subs to convert:
Thanks a Lot redrocks.
- Four bytes of an array in a float number: FourBytesToFloat
- One float number in four bytes in an array: FloatToFourBytes
********************************
Sub FourBytesToFloat(buffer() As Byte) As Float
' Thanks a Lot to "redrocks" member of basic4android forum.
Dim raf As RandomAccessFile
Dim value As Float
raf.Initialize3(buffer,True) ' Pass the byte buffer to raf
value=raf.ReadFloat(raf.CurrentPosition) ' save the float from buffer
raf.close 'Now the transmitted float is in variable "value"
Return value
End Sub
********************************
Sub FloatToFourBytes(value As Float) As Byte()
Dim raf1 As RandomAccessFile
Dim buffer(4) As Byte
raf1.Initialize3(buffer,True) ' Pass the byte buffer to raf
raf1.WriteFloat(value,raf1.CurrentPosition) ' save the float in the 4 bytes buffer
raf1.close
Return buffer
End Sub
********************************