Author Topic: Hexadecimal to Decimal conversion  (Read 6935 times)

Intrigue

  • Novice
  • **
  • Posts: 23
    • View Profile

  • Total Badges: 0
    Badges: (View All)
Hexadecimal to Decimal conversion
« on: December 20, 2005, 05:49:03 am »
Another thing that the MSDN library wasn't too clear on when I searched; after scouring the Internet and rejecting the huge functions, I found this very easy method:

dec=val("&h" & hex)

I tried a similar approach, but managed to forget to add the "&h" first!

Intrigue
friendly
0
funny
0
informative
0
agree
0
disagree
0
pwnt
0
like
0
dislike
0
late
0
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions

sarge

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • RACEVB6

  • Total Badges: 0
    Badges: (View All)
Re: Hexadecimal to Decimal conversion
« Reply #1 on: December 27, 2005, 02:58:18 pm »
dim x as double
x = val("&hFFFFFFFF)

X should be 4294967295, but it's calculated as -1.  This is a problem with the HEX function, it won't work over 7FFFFFFF.  Even adding the "&" at the end doesn't force a 32 bit calculation, even if the variable will hold a 64 bit number.

Sarge
friendly
0
funny
0
informative
0
agree
0
disagree
0
pwnt
0
like
0
dislike
0
late
0
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions

Intrigue

  • Novice
  • **
  • Posts: 23
    • View Profile

  • Total Badges: 0
    Badges: (View All)
Re: Hexadecimal to Decimal conversion
« Reply #2 on: December 27, 2005, 04:28:21 pm »
Thanks Sarge, nice to know someone's still alive after Christmas!

Intrigue
friendly
0
funny
0
informative
0
agree
0
disagree
0
pwnt
0
like
0
dislike
0
late
0
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions