Is it possible to go
CopyMemory Dest, Source + 1, -1 ?
I dunno maybe if i did 1&.
vb6 has no support for unsigned integers. only unsigned bytes.
The first statement is more of just a security precaution incase if the uint ends up >= 32678. Which will bring back the signed integer value from a signed long, os i don't get an overflow error. Then vb will automatically convert that back to integer. Although i could probably just put exit sub, but its kinda there just incase.
For signed numbers as soon as you go past the limit it starts going backwards. A 3bit signed integer would go, 0 1 2 3 -4 -3 -2 -1. So to get -1 you would need 111 which is an unsigned value of 7 (the maximum possible) .That means to turn an integer > 32677 into an signed integer, you have to bitwise OR with FFFF on the left word to flip it.
You were correct on the second statement, but i will hopefully enlighten you with the first statement.
I will explain it in logical terms, because if i explained it in bitwise terms, only you would understand.
If the Last Bit of the Left-Most Bit = True, then the byte value must be >= 128 (or signed -128), but because it is the left-most bit, then the actual number must be > 32677, outside the range of a signed integer.
Bitshift 8 bits to the left using the the long of Hex100 (using the trailing & to declare it as long), making those 8 bits the most significant bits.
Lets say the value of the bytes were MSB=128 and LSB=255. This should give a Unsigned value of 33023.
That means for the first stage.
Then OR the 2 bytes together.
This number because of the bitshift using a long, now has 16 preceding 0's.
If you OR
Which is the Unsigned Long value of 4294934783.
Which is the Signed Long value of -32512. Which is a safe integer value that doesn't cause an overflow.
Yeh now that i look at it, its extremely pointless.