Public Function Log10( _
ByVal dblValue As Double) _
' Returns Log 10 of input dblValue.
' No error handling as this should be handled
' outside this function.
' If dblMyValue > 0 then
' dblLogMyValue = Log10(dblMyValue)
' ' Do something else ...
' End If
Log10 = Log(dblValue) / Log(10)
Open in new window
The natural logarithm is the logarithm to the base e. The constant e is approximately 2.718282.
You can calculate base-n logarithms for any number x by dividing the natural logarithm of x by the natural logarithm of n as follows:
Logn(x) = Log(x) / Log(n)
The following example illustrates a custom Function that calculates base-10 logarithms:
Static Function Log10(X)
Log10 = Log(X) / Log(10#)
IT issues often require a personalized solution. With Ask the Experts™, submit your questions to our certified professionals and receive unlimited, customized solutions that work for you.