hex to decimal

1. Senior Member
Join Date
Dec 1969
Posts
248

## hex to decimal

ok, i looked through the docs for this and all i see is how to convert to hex from decimal. is there any functions i&#039;m not seeing that convert back to decimal or do i have to make my own hex conversion function?<BR><BR>justin

2. Senior Member
Join Date
Dec 1969
Posts
248

## i got it sort of..

i&#039;ve made my own hex to dec function, but i sure wish there was a better way than adding yet another function to my include file. does anyone else find it funny that vbscript has a dec to hex function but not the reverse? i checked the jscript docs and all you jscript fans out there (atrax ;) cannot chime in this time and say "well use jscript!". haha.<BR><BR>here&#039;s the function, i welcome criticism on it :)<BR><BR>function hexToDec(sHexVal)<BR> dim iLen, sHex, sTemp, i<BR><BR> sHexVal = ucase(sHexVal)<BR> iLen = len(sHexVal)<BR> sHex = 0<BR> sTemp = 0<BR> for i = 1 to iLen<BR> sHex = mid(sHexVal, i, 1)<BR> if not(isnumeric(sHex)) then<BR> select case sHex<BR> case "A"<BR> sHex = 10<BR> case "B"<BR> sHex = 11<BR> case "C"<BR> sHex = 12<BR> case "D"<BR> sHex = 13<BR> case "E"<BR> sHex = 14<BR> case "F"<BR> sHex = 15<BR> case else<BR> sHex = 0<BR> end select<BR> end if<BR> sHex = sHex * (16 ^ (iLen - i))<BR> sTemp = sTemp + sHex<BR> next<BR> hexToDec = sTemp<BR>end function<BR><BR><BR>-justin

3. Senior Member
Join Date
Dec 1969
Posts
549

## Javascript parseInt function

You could use Javascript...<BR><BR>parseInt(numstring, [radix]) <BR>The parseInt method syntax has these parts: <BR><BR>numstring (Required): A string to convert into a number. <BR><BR>radix (Optional): A value between 2 and 36 indicating the base of the number contained in numstring. If not supplied, strings with a prefix of &#039;0x&#039; are considered hexidecimal and strings with a prefix of &#039;0&#039; are considered octal. All other strings are considered decimal. <BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
248

## RE: Javascript parseInt function

****, i guess i don&#039;t know js well enough to check the for the function i want. and i thought jscript people where in the same boat as me on this one! oh well. everything on my pages is in vbscript so that really isn&#039;t an option for me, but thankyou!<BR>

5. Senior Member
Join Date
Dec 1969
Posts
549

## RE: Javascript parseInt function

Ohhh go on, taint your nice VBScript with an ickle bit of JavaScript (you could put it in a separate inc file). You know you want to :)<BR><BR>&#060;script language="JavaScript" runat="server"&#062;<BR>function convertHex(strHex) {<BR> return parseInt(strHex,16)<BR>}<BR>&#060;/script&#062;<BR><BR>Then again you can&#039;t beat writing your own function for satisfaction value.

#### Posting Permissions

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