ACOS 'Sub or Function Not Defined'

F

FizzyBunghole

Hi People,

Can anyone help me with this please? I want to do some trigonometry
calculations in VISIO vba (2003) and I can see the ACOS function in the vba
HELP, but I can't use it. At runtime it fails with a "Sub Or Function not
defined" error.

Any ideas? Is this yet another thing Visio is lacking or have I done a
booboo somewhere? Failing that, does anyone know how to work out the angle
when I know the cosine value? :)

Many thanks,

Tim
 
A

Al Edlund

Where Acos is listed as VBA, the only place I found it referenced is in the
Excel libraries. For some code to create the math you might check this site
out.

http://translate.google.com/transla...&hl=en&lr=&rls=RNWE,RNWE:2005-25,RNWE:en&sa=N

here's just the trig functions.

al


' compilé et testé par Walter Stucki Network Computing International

Function ACos(X As Double) As Double
' Arccosinus identique à ACOS d'Excel
ACos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function

Function ArcCos(X As Double) As Double
' Inverse du Cosinus
If X = 1 Then
ArcCos = 0
ElseIf X = -1 Then
ArcCos = -PI()
Else
ArcCos = Atn(X / Sqr(-X * X + 1)) + PI() / 2
End If
End Function

Function Arccosec(X As Double) As Double
' Inverse de la Cosécante
Arccosec = Atn(X / Sqr(X * X - 1)) + (Sgn(X) - 1) * PI() / 2
End Function

Function Arccotan(X As Double) As Double
' Inverse de la Cotangente
Arccotan = Atn(X) + PI() / 2
End Function

Function ArcSec(X As Double) As Double
' Inverse de la Sécante
ArcSec = Atn(X / Sqr(X * X - 1)) + Sgn(Sgn(X) - 1) * PI() / 2
End Function

Function ArcSin(X As Double) As Double
' Inverse du Sinue
If X = 1 Then
ArcSin = PI() / 2
ElseIf X = -1 Then
ArcSin = -PI() / 2
Else
ArcSin = Atn(X / Sqr(-X * X + 1))
End If
End Function

Function ATan2(X As Double, Y As Double) As Double
' Retourne l'ArcTangente basé sur les coordonnées de X et Y
' Si X et Y sont tous deux à zéro une erreur se produit.
' La valeur de l'axe des X est supposée être +0, allant dans le sens positif
dans la direction
' opposée aux aiguilles d'une montre, et dans le sens négatif dans le sens
des aiguilles d'une montre.
If X = 0 Then
If Y = 0 Then
ATan2 = 1 / 0
ElseIf Y > 0 Then
ATan2 = PI() / 2
Else
ATan2 = -PI() / 2
End If
ElseIf X > 0 Then
If Y = 0 Then
ATan2 = 0
Else
ATan2 = Atn(Y / X)
End If
Else
If Y = 0 Then
ATan2 = PI()
Else
ATan2 = (PI() - Atn(Abs(Y) / Abs(X))) * Sgn(Y)
End If
End If
End Function

Function Cosec(X As Double) As Double
' Cosécante
Cosec = 1 / Sin(X)
End Function

Function Cotan(X As Double) As Double
' Cotangente
Cotan = 1 / Tan(X)
End Function

Function Deg2Rad(X As Double) As Double
' Conversion de degrés en radians
Deg2Rad = X / 180 * PI()
End Function

Function HArccos(X As Double) As Double
' Inverse du Cosinus Hyperbolique
HArccos = Log(X + Sqr(X * X - 1))
End Function

Function HArccosec(X As Double) As Double
' Inverse de la Cosécante Hyperbolique
HArccosec = Log((Sgn(X) * Sqr(X * X + 1) + 1) / X)
End Function

Function HArccotan(X As Double) As Double
' Inverse de la Tangente Hyperbolique
HArccotan = Log((X + 1) / (X - 1)) / 2
End Function

Function HArcsec(X As Double) As Double
' Inverse de la Sécante Hyperbolique
HArcsec = Log((Sqr(-X * X + 1) + 1) / X)
End Function

Function HArcsin(X As Double) As Double
' Inverse du Sinus Hyperbolique
HArcsin = Log(X + Sqr(X * X + 1))
End Function

Function HArctan(X As Double) As Double
' Inverse de la Tangente Hyperbolique
HArctan = Log((1 + X) / (1 - X)) / 2
End Function

Function HCos(X As Double) As Double
' Cosinus Hyperbolique
HCos = (Exp(X) + Exp(-X)) / 2
End Function

Function HCosec(X As Double) As Double
' Cosécante Hyperbolique = 1/HSin(X)
HCosec = 2 / (Exp(X) - Exp(-X))
End Function

Function HCotan(X As Double) As Double
' Cotangente Hyperbolique = 1/HTan(X)
HCotan = (Exp(X) + Exp(-X)) / (Exp(X) - Exp(-X))
End Function

Function HSec(X As Double) As Double
' Sécante Hyperbolique = 1/HCos(X)
HSec = 2 / (Exp(X) + Exp(-X))
End Function

Function HSin(X As Double) As Double
' Sinus Hyperbolique
HSin = (Exp(X) - Exp(-X)) / 2
End Function

Function HTan(X As Double) As Double
' Tangente Hyperbolique = HSin(X)/HCos(X)
HTan = (Exp(X) - Exp(-X)) / (Exp(X) + Exp(-X))
End Function

Function PI() As Double
PI = Atn(1) * 4
End Function

Function Rad2Deg(X As Double) As Double
' Conversion de Radians en Degrés
Rad2Deg = X / PI() * 180
End Function

Function Sec(X As Double) As Double
' Sécante
' Attention à PI/2 et 3PI/2 radians (90 & 270 degrés)
Sec = 1# / Cos(X)
End Function
 
F

FizzyBunghole

Thanks Al. I just assumed that if you pressed help in Visio VBA, you got
help just for Visio...! You learn something every day! Many thanks for this
, I really appreciate you taking the time to help.

Best regards,

Tim
 

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