Question: Will the format of the input string always be 0x??0x??0x??, or will there be times when it's 0x???????? (single 0x at beginning) where the difference is that anything with multiple 0x values in it would be considered a string, and single values would be a number?
Building on Jure's code, this will return a string based on your sample.
function string uf_Hex2Dec ( string as_Hex ) // This function assumes incoming format will always be 0x?? repeated 0 or more times if isnull(as_Hex) then return as_hex if trim(as_Hex) = "" then return "" CONSTANT STRING ls_HexSet = "0123456789ABCDEF" STRING ls_Hex, ls_Bit, ls_RetVal INTEGER li_C, li_Len, li_Pos ls_Hex = Upper( as_Hex ) li_Len = Len( ls_Hex ) ls_RetVal = "" FOR li_C = 1 TO li_Len step 4 ls_Bit = Mid(ls_Hex, li_C + 2, 1) li_Pos = (Pos(ls_HexSet, ls_Bit) - 1) * 16 ls_Bit = Mid(ls_Hex, li_C + 3, 1) li_Pos += (Pos(ls_HexSet, ls_Bit) - 1) ls_RetVal += char(li_Pos) Next RETURN ls_RetVal
And if you always need it to return a Long, you can use "Return long(ls_RetVal)" and change the function return type to match.
Hope this helps.