-----------------------------------
pari
Tue May 24, 2011 1:30 pm
sin button doesnt work
-----------------------------------
can someone help me wit my sin button
this what i tried:
Private Sub cmdSin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSin.Click
num1 = Double.Parse(txtC.Text)
txtC.Text = " "
op = "sin"
txtC.Text = (Math.Sin(num1) * Math.PI / 180)
-----------------------------------
Tony
Tue May 24, 2011 2:01 pm
RE:sin button doesnt work
-----------------------------------
In what way does this not work?
-----------------------------------
Nick
Tue May 24, 2011 2:34 pm
RE:sin button doesnt work
-----------------------------------
I have two suggestions however I do not know how well either will work, sometimes there's a rounding error when dividing ints and doubles, try dividing by 180.0 instead.
Also I noticed you have brackets around your calculation, I think VB implicitly casts, but just to be sure why not explicitly cast the calculation to string
-----------------------------------
z_cross_fire
Tue May 24, 2011 8:56 pm
Re: sin button doesnt work
-----------------------------------
can someone help me wit my sin button
this what i tried:
Private Sub cmdSin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSin.Click
num1 = Double.Parse(txtC.Text)
txtC.Text = " "
op = "sin"
txtC.Text = (Math.Sin(num1) * Math.PI / 180)
The last line should instead be:
txtC.Text = Math.Sin(num1 * Math.PI / 180)
The angle must be converted to radians BEFORE using it in the Math.Sin(x) function.