converting back from Hex!

# Thread: converting back from Hex!

1. Senior Member
Join Date
Dec 1969
Posts
102

## converting back from Hex!

I have a Hex number A8 in the string variable Q<BR>How do I get the descimal value from Q?<BR>&HQ& does not work.<BR>Thanks!<BR><BR>Ray

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

## Just use CLng

It&#039;ll convert it for ya.

3. Senior Member
Join Date
Dec 1969
Posts
1,849

## Logically

Clng works.<BR><BR>Or... You could manually convert it...<BR>As you know, hex is bace 16 so your fields start (from the right) at 1, then 16, then 256, so on and so fourth...<BR>take the number in each field and multiply it by the value of that field.<BR><BR>So... you have A8<BR>a = 10<BR>B = 11<BR>C = 12<BR>D = 13<BR>E = 14<BR>F = 15<BR>value = 8*1 = 8<BR>value = value + (A*16)<BR><BR><BR>Or... you can throw it into a loop...<BR>number="FA8"<BR>total = 0<BR><BR>for i = 0 to len(number)-1<BR> current = left(right(number,i+1),1)<BR> select case current<BR> case "A"<BR> current=10<BR> case "B"<BR> current=11<BR> case "C"<BR> current=12<BR> case "D"<BR> current=13<BR> case "E"<BR> current=14<BR> case "F"<BR> current = 15<BR> end select<BR> total = total + (int(current) * 16^i)<BR> next<BR>response.write(total)

#### Posting Permissions

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