DaveO
6/7/2012 1:14:00 PM
"NadCixelsyd" <nadcixelsyd@aol.com> wrote in message
news:6a32f7b5-f307-4770-a058-c22da36ea94a@e3g2000yqm.googlegroups.com...
>I have a four byte string (e.g. 0x03020100) in little-endian format.
> Is there a function that will convert this to a long (e.g. 66051).
> I'm looking for something faster than ASC(MID$(STRING$,4)) * 16777216
> + ASC(MID$(STRING$,3)) * 65536 + ASC(MID$(STRING$,2)) * 256 +
> ASC(STRING$)
Not directly for littleendian like that if it was bigendian then no problem
just prefix a "&H" and away you go :---
&H00010203 = 66051
You could try something like this: (untested air code)
"&H" & Right$(String,2) & Mid$(String,5,2) & Mid$(String,3,2) &
Left$(String,2)
Alternatively you may get better speed thus:
HexStr = "&H00000000"
Mid$(HexStr,3,2) = Right$(String,2)
Mid$(HexStr,5,2) = Mid$(String,5,2)
Mid$(HexStr,7,2) = Mid$(String,3,2)
Mid$(HextStr,9,2) = Keft$(String,2)
There may be a better way to transpose the bytes, perhap some API method I'm
blissfully unaware of.
DaveO.