What's the Meaning of &H1, &H8000, etc.? A Guide for Programmers

By Aurora Hexwell | Created on 2025-09-26 21:53:47

Written with a analytical tone 🧠 | Model: benevolentjoker/nsfwvanessa:latest

0:00 / 0:00

Title:

In programming, particularly in languages like Visual Basic (Classic), you may encounter hexadecimal numbers prefixed with an ampersand (&) and a 'H', such as &H1 or &H8000. These represent binary numbers in hexadecimal format, which are essential in various programming tasks.

What does the prefix '&H' mean?

In this context, the '&H' is short for "hexadecimal" and indicates that the following number is represented in base 16 (hexadecimal) instead of the usual decimal system. It's a way to easily write binary numbers with more readability and clarity.

Examples:

  • &H1 represents the decimal value 1
  • &H10 represents the decimal value 16
  • &H8000 represents the decimal value 32768

Understanding GetKeyState() function

In some programming scenarios, you might use the GetKeyState() function to check whether a specific key on the keyboard is pressed or not. The return value of this function is a 16-bit integer (short) that contains information about the key's status.

When checking for a specific key press, it's essential to apply a bitwise AND operation (&) with &H8000, which represents the high-order bit (128 in decimal). This is because GetKeyState() returns a combination of the low-order bits representing the key's status and the high-order bit indicating whether the key is toggled or not.

Example:

  • If the VK_SHIFT constant has a value of &H10, when it's pressed, GetKeyState(VK_SHIFT) will return 10000000 (binary representation), which is equal to decimal 32768. Applying a bitwise AND operation with &H8000 results in 1000000000000000, indicating that the Shift key is indeed down.

In summary, understanding the hexadecimal notation and its application in programming, particularly when working with keyboard input functions like GetKeyState(), can significantly improve your coding efficiency and accuracy. By recognizing the significance of '&H' prefixes and applying bitwise operations correctly, you'll be better equipped to handle various programming tasks that involve keyboard inputs.



Sources:
- [What are &H1, &H8000, etc.? | Tek-Tips] (https://www.tek-tips.com/threads/what-are-h1-h8000-etc.1080522/)
- [H1 in publisher | Tek-Tips] (https://www.tek-tips.com/threads/h1-in-publisher.1601129/)
- [Why does font-size not inherit ? | Tek-Tips] (https://www.tek-tips.com/threads/why-does-font-size-not-inherit.1050326/)
- [Why does'nt text-align:justify work? Help | Tek-Tips] (https://www.tek-tips.com/threads/why-doesnt-text-align-justify-work-help.1690560/)
- [Moving Aplications to a new screen in C# | Tek-Tips] (https://www.tek-tips.com/threads/moving-aplications-to-a-new-screen-in-c.1416749/)
- [Microsoft VBScript runtime error '800a01b6' | Tek-Tips] (https://www.tek-tips.com/threads/microsoft-vbscript-runtime-error-800a01b6.419805/)
- [Error: Only content controls are allowed directly in a ... - Tek-Tips] (https://www.tek-tips.com/threads/error-only-content-controls-are-allowed-directly-in-a-content-page.1504551/)
- [Coverage Paths | Tek-Tips] (https://www.tek-tips.com/threads/coverage-paths.1632312/)
- [Send 8-bit data over serial port; values over 3F are being set to 3F] (https://www.tek-tips.com/threads/send-8-bit-data-over-serial-port-values-over-3f-are-being-set-to-3f.1672795/)
- [Vb6 Excel Set Range NumberFormat | Tek-Tips] (https://www.tek-tips.com/threads/vb6-excel-set-range-numberformat.1702432/)