For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > September 2004 > API calls and &H1, &H2, &H4, &H8, ..., &H10, ..., H40000, ....









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author API calls and &H1, &H2, &H4, &H8, ..., &H10, ..., H40000, ....
Joe

2004-09-17, 8:55 pm

Okay, I came into VB without *ever* learning about the hexadecimal notation.
What do the following mean and what decimal numbers do they translate to?

&H10 (is this equal to 16?)
&H400 (is this equal to 256?)

If they are, why do I use these in API calls in lieu of 16 and 256?

Thank you ever so much!
--
Joe

VBA Automation/VB/C++/Web and DB development
Ken Halter

2004-09-17, 8:55 pm

Joe wrote:
> Okay, I came into VB without *ever* learning about the hexadecimal notation.
> What do the following mean and what decimal numbers do they translate to?
>
> &H10 (is this equal to 16?)


Yup...

> &H400 (is this equal to 256?)


&h400's = 1024.

> If they are, why do I use these in API calls in lieu of 16 and 256?


There's really no reason. Hex is easier to read and mentally process if
you're going to end up breaking the value up into numerical "words".
Each letter represents a nibble of data (4 bits). 2 letters per byte (8
bits) and so on.

fwiw, If you fire up Windows Calculator and select the 'View/Scientific'
menu, you'll have a way to calculate hex/binary/etc.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..
Duane Bozarth

2004-09-17, 8:55 pm

Joe wrote:
>
> Okay, I came into VB without *ever* learning about the hexadecimal notation.
> What do the following mean and what decimal numbers do they translate to?


>
> &H10 (is this equal to 16?)
> &H400 (is this equal to 256?)



> If they are, why do I use these in API calls in lieu of 16 and 256?
>
> Thank you ever so much!
> --
> Joe
>
> VBA Automation/VB/C++/Web and DB development

Duane Bozarth

2004-09-17, 8:55 pm

Joe wrote:
>
> Okay, I came into VB without *ever* learning about the hexadecimal notation.
> What do the following mean and what decimal numbers do they translate to?


Time to learn...although I don't see how anyone can get very far in any
programming language w/o understanding the rudiments of various number
bases...

> &H10 (is this equal to 16?)
> &H400 (is this equal to 256?)


Yes...

> If they are, why do I use these in API calls in lieu of 16 and 256?


Documentation purposes only...usually these will correspond to bit
fields in various control words and the actual "set" bits are more
easily seen in hex than in decimal.
Jeff Johnson [MVP: VB]

2004-09-17, 8:55 pm


"Joe" <Joe@discussions.microsoft.com> wrote in message
news:B34BD627-936E-409B-AC5B-127093BD7917@microsoft.com...

> Okay, I came into VB without *ever* learning about the hexadecimal

notation.
> What do the following mean and what decimal numbers do they translate to?
>
> &H10 (is this equal to 16?)


Yes.

> &H400 (is this equal to 256?)


1024, actually. If you know anything about number systems, hexadecimal is
simply a base-16 number system. (If you don't, that statement probably
didn't mean much to you.) You've got 4 * 16 ^ 2 in that number above.

> If they are, why do I use these in API calls in lieu of 16 and 256?


The biggest plus about hexadecimal is that since 16 is a power of 2, it's
very easy to convert base-16 numbers into base-2 (binary) numbers.
Specifically, every digit of a hexadecimal number (named a "nybble" by some
g who's never gotten laid in his life) maps to four binary digits (bits).
Therefore, you only have to learn 16 bit patterns (0 - F) to be able to
translate any hex number into binary. This is very handy when dealing with
values that are meant to be flags, i.e., where each bit indicates that
yes/no status of something. In fact, I only use hex notation for bit flags.
Plain old numbers I leave in decimal.


Duane Bozarth

2004-09-17, 8:55 pm

Duane Bozarth wrote:
>
> Joe wrote:

....
>
> Yes...


Oops...noticed I goofed...&H400 = 4*256 = 1024...
Larry Serflaten

2004-09-17, 8:55 pm


"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote
>
> There's really no reason. Hex is easier to read and mentally process if
> you're going to end up breaking the value up into numerical "words".


And if the parameter is used for bit flags.

Bit flags are values that simply use each individual bit as a Yes/No
indicator. With 8 bits in a byte, a single byte can represent 8 different
Yes/No conditions. To manipulate the bits in the value, VB's logical
operators are used, but to help visualize which bits are actually set,
it helps to see the value in hexidecimal.

For example a file that has the arributes archive, system, and hidden
set will have an attribute value of 38. But learning which attributes are
set from looking at a value like 38 is somewhat difficult:

Archive = 32 (&H20)
Directory = 16 (&H10)
Hidden = 2 (&H02)
ReadOnly = 1 (&H01)
System = 4 (&H04)

But when viewed in Hex ( &H26 ) it can easily (with practise) be
seen that the flags &H20, &H04, and &H02 are set.

(I am using &Hxx notation because that is how they must be entered
to be recognised by VB as hexidecimal notation)

Don't be by the difference between Value, and Notation.
The computer handles and stores values, the user enters them in
using some type of notation, so that:

X = 1
X = &H1
X = 1E+0

All assign the value 1 to X, but each use a different type of notation.

What that means is that an attribute of 38 has a value of 38, and it is
still a value of 38 when entered in hexidecimal notation (&H26)....

HTH
LFS


MikeD

2004-09-17, 8:55 pm


"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
news:enmZ1FOnEHA.644@tk2msftngp13.phx.gbl...
>
> fwiw, If you fire up Windows Calculator and select the 'View/Scientific'
> menu, you'll have a way to calculate hex/binary/etc.


Or, just to know what decimal value a hex value has, just print it in VB's
Immediate window.

? &H10
16
? &H400
1024

Easier than starting Calculator. <g>

Mike


Ken Halter

2004-09-20, 3:56 pm

MikeD wrote:
>
> Easier than starting Calculator. <g>
>
> Mike


Yeah... just pointing out the Calculator. You'd be surprised at the
number of people that don't know the Windows Calculator actually has
'Scientific' functionality.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..
Randy Birch

2004-09-21, 3:55 am

Did 'ya see the new 'skinned' calculator? ..

http://www.microsoft.com/downloads/...&DisplayLang=en


--


Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/


"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
news:e58OLiynEHA.1712@tk2msftngp13.phx.gbl...
: MikeD wrote:
: >
: > Easier than starting Calculator. <g>
: >
: > Mike
:
: Yeah... just pointing out the Calculator. You'd be surprised at the
: number of people that don't know the Windows Calculator actually has
: 'Scientific' functionality.
:
: --
: Ken Halter - MS-MVP-VB - http://www.vbsight.com
: Please keep all discussions in the groups..

Stefan Berglund

2004-09-21, 3:55 am

On Mon, 20 Sep 2004 21:20:59 -0400, "Randy Birch"
<rgb_removethis@mvps.org> wrote:
in <uzBxBl3nEHA.2904@TK2MSFTNGP15.phx.gbl>

>Did 'ya see the new 'skinned' calculator? ..
>
>http://www.microsoft.com/downloads/...&DisplayLang=en


Hi Randy-

You might want to include a disclaimer that says that the
download is only valid for XP clients since it doesn't appear to
work from a W2K box.


---
Stefan Berglund
Ken Halter

2004-09-21, 3:55 pm

Randy Birch wrote:
> Did 'ya see the new 'skinned' calculator? ..
>
> http://www.microsoft.com/downloads/...&DisplayLang=en


Actually, I haven't. I played with the one from 'XP Power Toys', which
was pretty . I haven't downloaded anything from MS since that
'Genuine Microsoft Windows' thingy popped up (of course my OS is
genuine... just haven't gone through the steps to prove it)

besides... no XP at work.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..
Ken Halter

2004-09-21, 3:55 pm

Stefan Berglund wrote:
> Hi Randy-
>
> You might want to include a disclaimer that says that the
> download is only valid for XP clients since it doesn't appear to
> work from a W2K box.


fwiw, that info shows in the 'System Requirements' section.

>
> ---
> Stefan Berglund


--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..
Veign

2004-09-21, 3:55 pm

The ''Genuine' thingy is optional and can be bypassed if you want to
download something like the calculator. Its an option on the screen
following the click to verify...

--
Chris Hanscom
MVP (Visual Basic)
http://www.veign.com
--

"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
news:OLcB4g%23nEHA.3460@TK2MSFTNGP15.phx.gbl...
> Randy Birch wrote:
http://www.microsoft.com/downloads/...&DisplayLang=en[color=darkred]
>
> Actually, I haven't. I played with the one from 'XP Power Toys', which
> was pretty . I haven't downloaded anything from MS since that
> 'Genuine Microsoft Windows' thingy popped up (of course my OS is
> genuine... just haven't gone through the steps to prove it)
>
> besides... no XP at work.
>
> --
> Ken Halter - MS-MVP-VB - http://www.vbsight.com
> Please keep all discussions in the groups..



Ken Halter

2004-09-21, 3:55 pm

Veign wrote:
> The ''Genuine' thingy is optional and can be bypassed if you want to
> download something like the calculator. Its an option on the screen
> following the click to verify...


Yeah... I saw that. Still. No XP. Nothing else to download for Win2k
except Windows Updates and won't do that without a doing a complete
drive image first.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..
Stefan Berglund

2004-09-21, 3:55 pm

On Tue, 21 Sep 2004 07:36:13 -0700, Ken Halter
<Ken_Halter@Use_Sparingly_Hotmail.com> wrote:
in <OdCBah#nEHA.3460@TK2MSFTNGP15.phx.gbl>

>Stefan Berglund wrote:
>
>fwiw, that info shows in the 'System Requirements' section.


Oops. It sure does, doesn't it? <g>


---
Stefan Berglund
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com