A function from hexadecimal to decimal?

# Thread: A function from hexadecimal to decimal?

1. Senior Member
Join Date
Dec 1969
Posts
380

## A function from hexadecimal to decimal?

Is there a function to convert hexadecimal to decimal?<BR>I know in VBscript there is a function to convert to hexadecimal. But can&#039;t seem to find the way back.

2. Senior Member
Join Date
Dec 1969
Posts
2,334

http://www.sonofsofaman.com/hobbies/code/hextodec.asp

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Except when it gives dumb answer

No function is needed!<BR><BR>Example:<BR><BR>&#060;%<BR>hexstrin g = "3FCD"<BR><BR>number = CLNG("&H" & hexstring)<BR>%&#062;<BR><BR>Presto.<BR><BR>If you prefix the hexadecimal string (and it *will* be a string) with "&H", then the CLNG (or CINT, with a limited range) function will happily convert the string for you.<BR><BR>Here&#039;s the humorous part: It converts the string to a number. But what form, internal to the computer, do you think that number takes? Ready?<BR><BR>BINARY! And since binary and hexadecimal are just different "views" of the same format, you just converted a hexadecimal string to a hexadecimal number. <BR><BR>It&#039;s only when you go to *DISPLAY* that number that VBScript converts the binary/hexadecimal into a *STRING* again, but this time into a decimal string.<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Actually, that was crappy code...

...even if the CLNG trick didn&#039;t exist.<BR><BR>Using a power-of operator completely needlessly. Ugh.<BR><BR>Oh, well.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•