Jump to content
The simFlight Network Forums

Offset-Codes in Visual Basic

Recommended Posts

I have a question about the Offset-Codes:

In Visual Basic the offset code 0231 is written &H231 (0 = &H).

No, "0" isn't replaced by "&H". The "&H" part just says "the following number is in in hexadecimal" -- the same as the prefix "0x" in C/C++.

Preceding 0's in a hexadecimal number mean EXACTLY the same as preceding 0's in a decimal number, or a number in any radix -- absolutely nothing, just zero! The offset 0231 is the same as 231 and 0000000000231. The number of 0's at the beginning are completely irrelevant. Same as decimal 0000001 is the same as .... 1, no larger, no smaller!

Whats about , the other beginnings like 1, 2, 3, ....?

They can begin with 1, 2, 3 or 000001, 000000002, 03, whatever you like.

The only thing to be aware of is the peculiarity of Microsoft VB to change any hexadecimal number larger than 7FFF into one starting FFFF... ("sign extension"). For instance, it changes &H8100 into &HFFFF8100. Why? No idea -- it is bad programming or bad design or a bug. It even changes &H00008100 into &HFFFF8100 !

Apparently, to stop it doing such stupid things you should add another & at the end. Thus:


which does actually compile as &H00008100 !


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.