Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Get sine cosine tangent hyperbolic sine cosine tangent values of angle using "Math class" VB and C#.net 2.0

Author: Maliha Atteeq
Download Source Code : 967_Math.zip

In this simple article you will learn that how we can get sine, cosine, tangent and hyperbolic sine cosine tangent values of an angle using "Math class" in VB and C # (.net 2.0).

 Sine:

To get the sine value of an angle we have static function of class Math named sin (). This function takes angle as double type value in parameter and returns double value which is the sine value of that angle.

To demonstrate make a window application. Drag one text box and one button on form.

Now write the following code on Button click event:

C#

private void btn_sin_Click(object sender, EventArgs e)

        {

            string str = txt_sin.Text;

            double angle=Convert.ToDouble(str);

            double ans;

            ans=System.Math.Sin(angle);

            MessageBox.Show(ans.ToString());

        }

VB

Private Sub btn_sin_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim str As String = txt_sin.Text

        Dim angle As Double = Convert.ToDouble(str)

        Dim ans As Double

        ans = System.Math.Sin(angle)

        MessageBox.Show(ans.ToString())

    End Sub

This is simple code to get the sine value of an angle.

Hyperbolic Sine:

To get the hyperbolic sine value of an angle we have static function of class Math named sinh (). This function takes angle as double type value in parameter and returns double value which is the hyperbolic sine value of that angle.

To demonstrate make a window application. Drag one text box and one button on form.

Now write the following code on Button click event:

C#

        private void btn_sinh_Click(object sender, EventArgs e)

        {

            string str = txt_sinh.Text;

            double angle = Convert.ToDouble(str);

            double ans;

            ans = System.Math.Sinh(angle);

            MessageBox.Show(ans.ToString());

        }

VB

Private Sub btn_sinh_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim str As String = txt_sinh.Text

        Dim angle As Double = Convert.ToDouble(str)

        Dim ans As Double

        ans = System.Math.Sinh(angle)

     MessageBox.Show(ans.ToString())

End Sub

This is simple code to get the hyperbolic sine value of an angle.

Cosine:

To get the cosine value of an angle we have static function of class Math named Cos (). This function takes angle as double type value in parameter and returns double value which is the cosine value of that angle.

To demonstrate make a window application. Drag one text box and one button on form.

Now write the following code on Button click event:

C#

private void btn_cos_Click(object sender, EventArgs e)

        {

            string str = txt_cos.Text;

            double angle = Convert.ToDouble(str);

            double ans;

            ans = System.Math.Cos(angle);

            MessageBox.Show(ans.ToString());

        }

VB

Private Sub btn_cos_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim str As String = txt_cos.Text

        Dim angle As Double = Convert.ToDouble(str)

        Dim ans As Double

        ans = System.Math.Cos(angle)

     MessageBox.Show(ans.ToString())

    End Sub

This is simple code to get the cosine value of an angle.

Hyperbolic Cosine:

To get the hyperbolic cosine value of an angle we have static function of class Math named Cosh (). This function takes angle as double type value in parameter and returns double value which is the hyperbolic cosine value of that angle.

To demonstrate make a window application. Drag one text box and one button on form.

Now write the following code on Button click event:

C#

private void btn_cosh_Click(object sender, EventArgs e)

        {

            string str = txt_cosh.Text;

            double angle = Convert.ToDouble(str);

            double ans;

            ans = System.Math.Cosh(angle);

            MessageBox.Show(ans.ToString());

        }

VB

Private Sub btn_cosh_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim str As String = txt_cosh.Text

        Dim angle As Double = Convert.ToDouble(str)

        Dim ans As Double

        ans = System.Math.Cosh(angle)

     MessageBox.Show(ans.ToString())

    End Sub

This is simple code to get the hyperbolic cosine value of an angle.

Tangent:

To get the tangent value of an angle we have static function of class Math named Tan (). This function takes angle as double type value in parameter and returns double value which is the tangent value of that angle.

To demonstrate make a window application. Drag one text box and one button on form.

Now write the following code on Button click event:

C#

private void btn_tan_Click(object sender, EventArgs e)

        {

            string str = txt_tan.Text;

            double angle = Convert.ToDouble(str);

            double ans;

            ans = System.Math.Tan(angle);

            MessageBox.Show(ans.ToString());

        }

VB

Private Sub btn_tan_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim str As String = txt_tan.Text

        Dim angle As Double = Convert.ToDouble(str)

        Dim ans As Double

        ans = System.Math.Tan(angle)

     MessageBox.Show(ans.ToString())

    End Sub

This is simple code to get the tangent value of an angle.

Hyperbolic Tangent:

To get the hyperbolic tangent value of an angle we have static function of class Math named Tanh (). This function takes angle as double type value in parameter and returns double value which is the hyperbolic tangent value of that angle.

To demonstrate make a window application. Drag one text box and one button on form.

Now write the following code on Button click event:

C#

private void btn_tanh_Click(object sender, EventArgs e)

        {

            string str = txt_tanh.Text;

            double angle = Convert.ToDouble(str);

            double ans;

            ans = System.Math.Tanh(angle);

            MessageBox.Show(ans.ToString());

        }

VB

Private Sub btn_tanh_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim str As String = txt_tanh.Text

        Dim angle As Double = Convert.ToDouble(str)

        Dim ans As Double

        ans = System.Math.Tanh(angle)

     MessageBox.Show(ans.ToString())

    End Sub

This is simple code to get the hyperbolic tangent value of an angle.

Now write the following code on FORM LOAD event:

C#

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DEVASP MATH APPLICATION";          

        }

VB

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)

        Me.Text = "DEVASP MATH APPLICATION"

    End Sub

This simple article tells that how we can get sine, cosine, tangent and hyperbolic sine cosine tangent values of an angle using "Math class" in VB and C # (.net 2.0).

Article Comments
According to ur code we will get the result in the message box but i didn't wanna to see it there , i wanna see in the textbox itself in the calculator,could anyone help me in doing this

Posted on 3/18/2010 4:09:16 AM by febin

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Generate double type pseudo random numbers and populating byte array with random numbers VB and C# using .net 2.0.

Disclaimer - Privacy
© 2002-2017 DevASP.net