Convert Byte Array to Double. 
Author Message
 Convert Byte Array to Double.

Haya -

Does anyone have a good idea how to convert a Byte array to a Double?  I can
go the other way using LSet but I can't get that to work in this case

(The Type with the byte has to be the assignee otherwise it give a Type
mismatch).

Thanks in Advance!!!



Tue, 12 Mar 2002 03:00:00 GMT  
 Convert Byte Array to Double.
Tad,

You can use the Windows API CopyMemory function.  The code below copies a double
to a byte array and back to another double.

John.......

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination
As Any, Source As Any, ByVal Length As Long)

    Dim ab() As Byte
    Dim d1 As Double, d2 As Double
    Dim i As Integer

    d1 = 1234.56
    ReDim ab(7)
    Call CopyMemory(ab(0), d1, 8)

    For i = 0 To 7
        Debug.Print ab(i)
    Next

    Call CopyMemory(d2, ab(0), 8)

    Debug.Print d2

Quote:

> Haya -

> Does anyone have a good idea how to convert a Byte array to a Double?  I can
> go the other way using LSet but I can't get that to work in this case

> (The Type with the byte has to be the assignee otherwise it give a Type
> mismatch).

> Thanks in Advance!!!



Tue, 12 Mar 2002 03:00:00 GMT  
 Convert Byte Array to Double.
Got it.  Thanks

Quote:
> Tad,

> You can use the Windows API CopyMemory function.  The code below copies a
double
> to a byte array and back to another double.

> John.......

> Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
(Destination
> As Any, Source As Any, ByVal Length As Long)

>     Dim ab() As Byte
>     Dim d1 As Double, d2 As Double
>     Dim i As Integer

>     d1 = 1234.56
>     ReDim ab(7)
>     Call CopyMemory(ab(0), d1, 8)

>     For i = 0 To 7
>         Debug.Print ab(i)
>     Next

>     Call CopyMemory(d2, ab(0), 8)

>     Debug.Print d2


> > Haya -

> > Does anyone have a good idea how to convert a Byte array to a Double?  I
can
> > go the other way using LSet but I can't get that to work in this case

> > (The Type with the byte has to be the assignee otherwise it give a Type
> > mismatch).

> > Thanks in Advance!!!



Tue, 12 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Convert byte array to double? VB5.0

2. Convert Byte Array To Double

3. Convert Byte Array to Double using CopyMemory

4. converting floating point dtaa from byte array to DOUBLE

5. Need to convert a 16 byte array of bytes to 4 byte integer

6. Converting a string array into a double array

7. Converting string array to byte array

8. how to use asp convert BIG5 ( Double bytes code ) to unicode (wml page )

9. converting double value into bytes

10. byte array to double

11. Double to Byte Array and Back

12. find double byte characters in a single byte string

 

 
Powered by phpBB® Forum Software