Win32+API+constants

When you view API function documentation, you'll often see function constant values represented like so:


 * 1) define URL_ESCAPE_UNSAFE 0x20000000

In this expression, the constant's name, URL_ESCAPE_UNSAFE, is followed by the Hex value, 0x20000000. In VB, of course, this declaration might look something like the following:

Private Const URL_ESCAPE_UNSAFE As Long = 0x20000000

However, Visual Basic won't recognize the 0x20000000 format. As a result, you'll need to convert these kinds of values into either VB Hex format or their decimal value.

As you may know, the 0x portion of any Hex value is really just a notation to signify that the value is in Hex, as opposed to regular Decimal or other number format. In VB, to indicate a Hex value you precede it with &H. With this in mind,

0x20000000

becomes

&H20000000

As a result, the previous constant declaration would look as follows in VB

Private Const URL_ESCAPE_UNSAFE As Long = &H20000000

In part 2 of this tip, we'll show you a quick and easy way to get the decimal value from a Hex.