[thelist] Hex to Decimal (Was: ASP URLDecode)

Cymbala, Greg Greg.Cymbala at Den.Galileo.com
Fri May 3 12:20:04 CDT 2002


How about this, which takes a character, converts it to hex, then back to a
character ...

Dim vHexNum, iInteger, vChar

vChar = "W"

iInteger = Asc(vChar)

vHexNum = "&H" & Hex(iInteger)
Response.Write ("<p>vHexNum = " & vHexNum & "</p>")

iInteger = CInt(vHexNum)
Response.Write ("<p>iInteger = " & iInteger & "</p>")

vChar = Chr(iInteger)
Response.Write ("<p>vChar = " & vChar & "</p>")


VBScript understangs things prefixed by "&H" to be hexadecimal numbers:

"You can represent hexadecimal numbers directly by preceding numbers in the
proper range with &H. For example, &H10 represents decimal 16 in hexadecimal
notation."

If all you've got is a string that you know is a hex number like "3F", just
previx it with "&H" and do a CInt (or whatever numeric conversion you want)
on it.

Greg


The information in this electronic mail message is sender's business
Confidential and may be legally privileged.  It is intended solely for the
addressee(s).  Access to this Internet electronic mail message by anyone
else is unauthorized.  If you are not the intended recipient, any
disclosure, copying, distribution or any action taken or omitted to be taken
in reliance on it is prohibited and may be unlawful.
The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message and
its attachments could have been infected during  transmission. By reading
the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. Galileo International is not liable for any loss or damage
arising in any way from this message or its attachments.





More information about the thelist mailing list