Convert Hexadecimal Number To Decimal Number
Create Funtion gf_Hex2Dec
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
//[powerscript] /**********************************************/ /* public long gf_Hex2Dec ( string as_Hex ) */ /**********************************************/ Constant String ls_HexSet = "0123456789ABCDEF" String ls_Hex, ls_Bit Long ll_Div, ll_RetVal = 0 Integer li_C, li_Len, li_Pos Boolean lb_Error = False ls_Hex = Upper( as_Hex ) If Not IsNull( ls_Hex ) And ls_Hex <> "" Then li_Len = Len( ls_Hex ) For li_C = 1 To li_Len ls_Bit = Mid( ls_Hex, li_C, 1 ) li_Pos = Pos( ls_HexSet, ls_Bit ) If li_Pos = 0 Then lb_Error = True Else ll_RetVal += ( ( li_Pos - 1 ) * ( 16 ^ ( li_Len - li_C ) ) ) End If Next If lb_Error Then ll_RetVal = 0 End If Return ll_RetVal |
Good Luck!
Subscribe
Login
0 Comments
Oldest