Here is another way to convert hex to digit, hex to decimal:
Code:
<% @language="VBScript" %>
<% option explicit %>
<%

  '--------------
  ' Hex2Dgt()
  '------------------------------------------
  ' input:  one hex-char 0..9, a..f, A..F
  ' return: a number 0..15
  ' note: no error-checking
  '------------------------------------------
Function Hex2Dgt(ByVal inHexChar)
  If ( inHexChar <= "9" ) Then
    Hex2Dgt = Asc(inHexChar) - Asc("0")
  Else
    Hex2Dgt = Asc(uCase(inHexChar)) - Asc("A") + 10
  End If
End Function

  '--------------
  ' Hex2Dec()
  '------------------------------------------
  ' input: a Hex string
  ' return:
  '     -2 null string
  '     -1 error (non-hex char)
  '   >= 0 the converted value
  '------------------------------------------
Function Hex2Dec(ByVal inHex)
  
  Dim oREX : Set oREX = New RegExp
  Dim nVal : nVal = 0
  Dim i

    ' test if null-string
    '
  If ( inHex="") Then
    Hex2Dec = -2
    Exit Function
  End If

    ' test any non-hex char
    '
  oREX.Pattern = "[^0-9A-Fa-f]"
  If ( oREX.Test(inHex)) Then
    Hex2Dec = -1
    Exit Function
  End If

    ' now do the conversion
    '
  For i=1 to Len(inHex)
    nVal = nVal * 16 + Hex2Dgt(Mid(inHex,i,1))
  Next

  Hex2Dec = nVal
  set oREX = Nothing

End Function


  ' test
  '
Dim aryHex(6) 
Dim ix

aryHex(0) = "00000000000000000000000000"
aryHex(1) = "7fffffff"            ' max for Hex()
aryHex(2) = "ffffffffffff"        ' 12-f
aryHex(3) = "deadbeef0123456789bad"
aryHex(4) = ""
aryHex(6) = "hex"

For ix=0 to UBound(aryHex)
  Response.Write aryHex(ix) & " : " & Hex2Dec(aryHex(ix)) & "<br/>" & vbCRLF
Next

%>
Results:
Code:
00000000000000000000000000 : 0
7fffffff : 2147483647
ffffffffffff : 281474976710655
deadbeef0123456789bad : 1.68251264662152E+25
: -2
: -2
hex : -1