Aastii
VIP Member
I am making a calculator in VB 2008 and trying to put in trig functions.
Now I know that when you do any trig function in VB it comes out in radians rather than degrees, and to convert from radians to degrees you must *Pi/180, however whenever I do it, it comes out wrong.
My code is:
Private Sub cmdSine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSine.Click
FirstNumber = txtFirstNumber.Text
Answer = (Math.Sin(FirstNumber)) * (Math.PI / 180)
txtAnswer.Text = Answer
End Sub
Which should come out with the right answer, so to test it I did Sin 90 (or tried to) which should come out with 1 exactly, but it came out as 0.01560.....
Is it a mistake in VB, or am I missing something here?
Now I know that when you do any trig function in VB it comes out in radians rather than degrees, and to convert from radians to degrees you must *Pi/180, however whenever I do it, it comes out wrong.
My code is:
Private Sub cmdSine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSine.Click
FirstNumber = txtFirstNumber.Text
Answer = (Math.Sin(FirstNumber)) * (Math.PI / 180)
txtAnswer.Text = Answer
End Sub
Which should come out with the right answer, so to test it I did Sin 90 (or tried to) which should come out with 1 exactly, but it came out as 0.01560.....
Is it a mistake in VB, or am I missing something here?