| Convert API constant Hex formats into VB-friendly Hex values When you view API function documentation, you'll often see function constant values represented like so: #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 When you declare an API constant, however, you can also use a standard decimal value, if you so choose. Believe it or not, to quickly convert a Hex value into its decimal equivalent, you can use Windows own built-in Calculator. To see what we mean, launch the Calculator application. Next, select View | Scientific from the menubar. When you do, the calculator expands to include a host of scientific functions. Near the top, it also lets you choose the format in which you wish to view the numbers, Hex and Dec included. By entering a Hex number into the entry field and then selecting the Dec option, we can quickly convert from one format to the next. For example, in the Calculator select the Hec option, and then enter 2000000. Now, switch to Dec. When you do the calculator displays the number 33554432. You can then use this number as the value of the API function constant, like so: Private Const URL_ESCAPE_UNSAFE As Long = 33554432 |
Convert API constant Hex formats |
India web developer web development India | India web development company India ecommerce web developer