Hex2Dec

Converts hexadecimal strings into decimals

Function Hex2Dec(strHex)
 dim lngResult, intIndex, strDigit, intDigit, intValue
 lngResult     = 0
 For intIndex = len(strHex) to 1 step -1
  strDigit    = mid(strHex, intIndex, 1)
  intDigit    = instr("0123456789ABCDEF", ucase(strDigit))-1
  If intDigit >= 0 then
   intValue   = intDigit * (16 ^ (len(strHex)-intIndex))
   lngResult   = lngResult + intValue
  Else
   lngResult  = 0
   intIndex   = 0 ' stop the loop
  End if
 Next
 Hex2Dec     = lngResult
End Function

strHex

Views 2367 Downloads 811


ANmarAmdeen
589
Math Classic ASP
Revisions

v2.0