none
How do I get Arccosine in Visual Basic for Applications RRS feed

  • Question

  • When I use the Acos() function in VB for Appl. I get Compile error: function not defined. How do I calculate the arccosine
    Saturday, July 11, 2015 7:28 PM

Answers

All replies

  • When I use the Acos() function in VB for Appl. I get Compile error: function not defined. How do I calculate the arccosine

    Use Math.Acos

    Still lost in code, just at a little higher level.

    :-)

    Saturday, July 11, 2015 7:45 PM
  • Or Import System.Math to use Math Methods withot prefixing them with "Math.".

    La vida loca

    Saturday, July 11, 2015 10:18 PM
  • Thanks but now I get Method or data member not found. When I code Math., the Acos is not an option. cos, sin, tan and atn are. Any other way to get to it?
    Sunday, July 12, 2015 4:33 AM
  • Thanks but now I get Method or data member not found. When I code Math., the Acos is not an option. cos, sin, tan and atn are. Any other way to get to it?

    Maybe in the project tab use add reference then in Assemblies select System.Math using the Imports System.Math statement in the code also.

    La vida loca

    Sunday, July 12, 2015 4:45 AM
  • And you won't find it here. Visit the VBA forum.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=isvvba


    Success
    Cor

    • Proposed as answer by Devon_Nullman Sunday, July 12, 2015 1:37 PM
    Sunday, July 12, 2015 11:18 AM
  • Hi Rick,

    The Acos() function is in WorksheetFunction object.

    Dim d As Double
    Dim r As Double
    d = 0.5
    r = Application.WorksheetFunction.Acos(d)

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 16, 2015 5:57 AM
    Moderator
  • How do I calculate the arccosine
    Function ArcCos(ByVal X As Double) As Double
      'Liefert den Arcus-Cosinus eines Winkels
      If Abs(X) > 1 Then
    #If RaiseError Then
        Err.Raise 6, , "ArcCos(x): x > 1"
    #Else
        X = 1 / X
    #End If
      End If
      If Abs(X) <> 1 Then
        ArcCos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
      Else
        ArcCos = IIf(X = 1, 0, Atn(1) * 4)
      End If
    End Function


    Thursday, July 16, 2015 7:07 AM