See Also Example
Returns the natural logarithm of a number.
The argument number can be any valid numeric expression The natural logarithm is the logarithm to the base e. The constant e is approximately 2.718282. that results in a value greater than 0.
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 Function procedure that calculates base-10 logarithms:
Static Function Log10(X)
Log10 = Log(X) / Log(10#)
Derived Math Functions
Log Function Example
The example calculates the value of e, then uses the Log function to calculate the natural logarithm of e to the first, second, and third powers. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
Dim I, Msg, NL ' Declare variables.
NL = Chr(13) & Chr(10) ' Define newline.
Msg = Exp(1) & NL
For I = 1 To 3 ' Do three times.
Msg = Msg & Log(Exp(1) ^ I) & NL
MsgBox Msg ' Display message.