excel中VBA函数 log10()

excel中VBA函数 log10()
Cells(3, k + 2).Value = Cells(6, 19) * Power((Cells(3, k) + 273) * (Log10(Cells(3, 30)) + Cells(2, 23)) / 1000, 2) + Cells(6, 20) * Power((Cells(3, k) + 273) * (Log10(Cells(3, 30)) + Cells(2, 23)) / 1000, 1) + Cells(6, 21) '将这个单元格的应力σ算出来

编辑器为什么说Log10()没有定义而报错,难道VBA中没有Log10()这个函数吗?
那么vba中Log10(),即以10为底的对数函数,该怎么写了?
LOG10是工作表函数,在VBA中要使察早用工蚂没蚂作表函数,必须通闷埋过 WorksheetFunction 对象:

Cells(3, k + 2).Value = Cells(6, 19) * Power((Cells(3, k) + 273) * (WorksheetFunction.Log10(Cells(3, 30)) + Cells(2, 23)) / 1000, 2) + Cells(6, 20) * Power((Cells(3, k) + 273) * (WorksheetFunction.Log10(Cells(3, 30)) + Cells(2, 23)) / 1000, 1) + Cells(6, 21)
vba中只有log()函数,表示的是自然对数函数,将 x 的自然对数毕燃值除以 n 的自然对数值,就可以对任意底 n 来计算数值 x 的卜洞对数值:
Logn(x) = Log(x) / Log(n)
下面的示例说明如何编写一型数枯个函数来求以 10 为底的对数值:
Static Function Log10(X)
Log10 = Log(X) / Log(10#)
End Function
← 上一篇: 下一篇: →