undefined function in "ACOS" expression

G

Guest

i am trying to calculate the arccosine of a number and keep getting an error
message:
undefined function in "ACOS" expression. I am following the syntax in the
help menu and my number is between -1 and 1 as specified.
Any suggestions?
 
F

fredg

i am trying to calculate the arccosine of a number and keep getting an error
message:
undefined function in "ACOS" expression. I am following the syntax in the
help menu and my number is between -1 and 1 as specified.
Any suggestions?

You have posted this message to the wrong news group.
The access in this newsgroup's title refers to Microsoft Access, a
database product.
ACOS is not an Access function.
If you are using Excel, I would suggest you post to the appropriate
Excel newsgroup.
 
J

James A. Fortune

fishcakes said:
i am trying to calculate the arccosine of a number and keep getting an error
message:
undefined function in "ACOS" expression. I am following the syntax in the
help menu and my number is between -1 and 1 as specified.
Any suggestions?

Public Function ACos(dblX As Double, strUnit As String) As Double
'strUnit = "Degree" for degrees and "Radian" for radians
Const Pi = 3.14159265358979
Dim dblThetaRad As Double

If dblX > 1 Or dblX < -1 Then
MsgBox ("Input outside of range for ACos function.")
ACos = 0
Exit Function
End If
If dblX = 1 Then
ACos = 0
Exit Function
End If
If dblX = -1 Then
If strUnit = "Degree" Then
ACos = 180
Else
ACos = Pi
End If
Exit Function
End If
'Microsoft's version from A97 help - Derived Math Functions
dblThetaRad = Atn(-dblX / Sqr(-dblX * dblX + 1)) + 2 * Atn(1)
'My version
dblThetaRad = Pi / 2 - Sgn(dblX) * Atn(Abs(dblX) / Sqr(1 - dblX ^ 2))
If strUnit = "Degree" Then
ACos = dblThetaRad * 180# / Pi
Else
ACos = dblThetaRad
End If
End Function

James A. Fortune
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top