Re: Hex--->Dec!
- From: Duane Bozarth <dpbozarth@xxxxxxxxxxxx>
- Date: Thu, 20 Oct 2005 10:42:07 -0500
Arpan wrote:
>
> Nope....Duane....that isn't what I am looking out for. Let me give you
> an example.
>
> Consider the decimal number 10. The hexadecimal equivalent of 10 is 'A'
> (without the quotes) which can be computed using Hex(10). Now I want a
> function that will convert the hexadecimal 'A' back to decimal 10.
That's <exactly> what I demonstrated...
Go through my example...
?hex$(10)
A
?"&H" & hex$(10)
&HA
So, "&H" & hex$(10), the argument to Val() is "&HA".
The &H is needed to satisfy VB's syntax rules to identify the string "A"
to Val() as being interpreted as a hex value.
?val("&H" & hex$(10))
10
> Similarly, the octal equivalent of 10 is 12 which can be computed using
> Oct(10). Now I want a function that will convert the octal 12 back to
> decimal 10.
Same thing...
> I hope I am clear enough now. ...
You're confusing internal and external representations, methinks...
The decimal value is stored internally as a bit pattern of 000010010
(upper bits implied and all 0). Whether you see "10" or "A" or "12" is
simply what base system is used for presentation--the internal
representation is unchanged.
As noted, there are syntax rules in VB regarding what you have to do to
present ASCII representations to various functions/statements to make
the interpretation and presentation as desired.
If you would describe the actual application/problem domain specific
solutions might be forthcoming.
.
- References:
- Hex--->Dec!
- From: Arpan
- Re: Hex--->Dec!
- From: Arpan
- Hex--->Dec!
- Prev by Date: Re: Iterative GetObject
- Next by Date: Re: Hex--->Dec!
- Previous by thread: Re: Hex--->Dec!
- Next by thread: Re: Hex--->Dec!
- Index(es):
Relevant Pages
|