Because the Integer to ByteArray function within the CDK provided COM functions 
isn't working for me under VB 5.0 (but the ByteArray to Integer function is 
working), I thought I'd attempt to perform the conversion from PC to Palm 
format on my own, and test it by using the Palm to PC format functions.  The 
text converter seems to work, at least in that the COM conversion function from 
bytearray to text reproduces the original text when sent the product of the 
function that I wrote.  

Unfortunately, the function that I was trying to get to work to perform the 
conversion from integer to byte array doesn't seem to be working properly.  

When I send the result to the COM function to convert it back to an integer 
(long) format that is suitable for the PC, nothing is displayed in the text box 
to which I send the result.  The VB code for the integer to byte array function 
follows.  Can anyone tell me what I'm doing wrong here?  (Note: I'm beyond the 
limits of my normal programming capabilities when it comes to manipulating 
memory directly, or dealing in byte arrays.  Please keep that in mind in any 
response.)

Thanks.

--------

Function LongToByteArray(ByVal lng As Long) As Variant

Dim frog As Variant
Dim ByteArray(0 To 3) As Byte
Dim FinArray(0 To 3) As Byte
CopyMemory ByteArray(0), ByVal VarPtr(lng), Len(lng)
'ByteArray is in Big Endian Format (Windows 98/Intel)
'Convert from Big Endian to Little Endian Format
FinArray(3) = ByteArray(0)
FinArray(2) = ByteArray(1)
FinArray(1) = ByteArray(2)
FinArray(0) = ByteArray(3)
'FinArray is in Little Endian Format
'Save FinArray as a Variant and Send Back to Calling Routine
frog = FinArray
LongToByteArray = frog

End Function
-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to