Quantcast
Channel: VBForums - Code It Better
Viewing all articles
Browse latest Browse all 16

Trig Math Operators

$
0
0
Hey Guys! I'm not sure what is wrong with my code exactly. It all looks accurate with me. Hopefully, someone can spot the error. When I ran the program it just returns a 0 where I should have the sine, cosine, or tangent number. Soo here's my code:

Public Class Form1

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub btnASine_Click(sender As Object, e As System.EventArgs) Handles btnASine.Click
Dim sine As Double
Dim num As Double
Dim number As Double
num = Me.txtVal.Text

RadiansToDegrees(number)
sine = Math.Round(Math.Asin(number), 2)

Me.Label2.Text = "An angle with sine " & num & " is " & sine & " degrees. "
End Sub

Private Sub btnACo_Click(sender As Object, e As System.EventArgs) Handles btnACo.Click
Dim cosine As Double
Dim number As Double
Dim num As Double
num = Me.txtVal.Text

RadiansToDegrees(number)
cosine = Math.Round(Math.Acos(number), 2)

Me.Label2.Text = "An angle with cosine " & num & " is " & cosine & " degrees. "
End Sub

Private Sub btnATan_Click(sender As Object, e As System.EventArgs) Handles btnATan.Click
Dim tan As Double
Dim number As Double
Dim num As Double
num = Me.txtVal.Text

RadiansToDegrees(number)
tan = Math.Round(Math.Atan(number), 2)

Me.Label2.Text = "An angle with cosine " & num & " is " & tan & " degrees. "
End Sub

Function RadiansToDegrees(ByVal degree As Double)
Dim number As Double
number = Me.txtVal.Text

Return degree = number * (180 / Math.PI)

End Function

End Class

Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>