Convert long integer? 
Author Message
 Convert long integer?

: Short question:
: How do I convert a 4-byte long integer stored in big-endian number
: (high byte first, low byte last) to a 'normal' long integer? I believe
: I have to seperate the high/low word, and this I know how to do, but
: after that then what?

 You can use the fact that Type'd variables can be assigned to one-another
with LSet regardless of contents.  So, assuming you want to reverse the order
of the four bytes before interpreting the integer, you could do something

 Type MyString
   S  As String*4
 End Type

 Type MyIntg
   I  As Long
 End Type

 Dim S as MyString, I As MyIntg

 Tmp$ = S.S    ' Assuming S.S contain the integer you want to convert
 S.S = Right$(Tmp$, 1) & Mid$(Tmp$, 3, 1) & Mid$(Tmp$, 2, 1) & Left$(Tmp$, 1)
 LSet I = S    ' At this point, I.I is the integer value you want.

Tue, 26 Aug 1997 08:55:54 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Help: converting long integer colour values to RGB

2. Converting integers and long integers to byte arrays

3. Overflow exceptions when converting from Long to Integer?

4. Converting integer (or long) data type to array of bytes

5. How to Convert a Long Integer (High/Lov)?

6. HELP: Converting to time_t (long integer) taking into account Daylight Hours

7. Long = Integer * Integer Overflow error

8. Date as long integer

9. Passing signed Long Integers to VB 6 From C++

10. routine to display long integer unsigned?

11. Long Integer Left Circular Shift

12. Store 2 integers in a long?


Powered by phpBB® Forum Software