Applecore Pages on Microsoft Access

Converting numbers between the various bases (Decimal, Hexadecimal, Octal)

Access has various functions built-in to enable you to convert numbers from decimal to both hexadecimal and octal, but doesn't have functions to convert back from these bases to decimal. Therefore, you need to use custom functions for this. Below are functions to convert from octal to decimal, and from hexadecimal to decimal:

Function fOct2Dec(ByVal strValue As String) As Long
    If Left(strValue, 2) <> "&O" Then strValue = "&O" & strValue
    fOct2Dec = CLng(strValue)
End Function

Function fHex2Dec(ByVal strValue As String) As Long
    If Left(strValue, 2) <> "&H" Then strValue = "&H" & strValue
    fHex2Dec = CLng(strValue)
End Function

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 14:56:56