两个有用的函数,使用时直接调用
1. 求以10为底的对数值的函数,如下:
Private Function LogTen(X As Double) As Double
'* 检验真数数有效性
If X <= 0 Then
MsgBox "真数的取值范围:真数>0.", vbInformation, "参数错误"
End If
'* 计算并返回对数值
LogTen = Log(X) / Log(10)
End Function
2. 求以任意数为底的对数值的函数,如下:
Private Function LogNtr(X As Double, n As Double) As Double
'* 检验底数数有效性
If n <= 0 Or n = 1 Then
MsgBox "底数的取值范围:底数>0 且<>1.", vbInformation, "参数错误"
End If
'* 检验真数数有效性
If X <= 0 Then
MsgBox "真数的取值范围:真数>0.", vbInformation, "参数错误"
End If
'* 计算并返回对数值
LogNtr = Log(X) / Log(n) '> 计算LognX的值
End Function
文章出处:飞诺网(www.firnow.com):http://dev.firnow.com/course/7_databases/database_other/20071019/78227.html
联系客服