Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: flick on July 11, 2009, 08:08:27 PM

Title: No acos/asin?
Post by: flick on July 11, 2009, 08:08:27 PM
There's an atn function, to calculate arctan's... but no inverse functions for the other two? Am I overlooking them somehow? I need them!
Title: Re: No acos/asin?
Post by: ger21 on July 11, 2009, 09:42:46 PM
Google "VB asin" and you see how to code them yourself. Apparently they are not included in VB.
Title: Re: No acos/asin?
Post by: flick on July 12, 2009, 03:21:47 AM
Thanks.  Those are a lot cleaner than the guess & test versions I came up with. ;)
Title: Re: No acos/asin?
Post by: morg2borg on May 22, 2011, 06:18:35 PM
Function ArcSin(X As Double) As Double
    ArcSin = Atn(X / Sqr(-X * X + 1))
End Function

Function ArcCos(X As Double) As Double
    ArcCos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function

Private Sub Command1_Click()
    ' replace the 0.5 below with the degree (in radians) that
    ' you want to calculate its ArcSin or ArcCos value
    MsgBox "ArcSin(0.5) = " & ArcSin(0.5)
    MsgBox "ArcCos(0.5) = " & ArcCos(0.5)
End Sub