Calculating ArcSin and ArcCos

There is no ArcSin and ArcCos functions in Visual Basic, but there is
ArcTan function, and you can use it to calculate both ArcSin and ArcCos.

Preparations

Add 1 Command Button to your form.

Form Code

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

Go Back