• Best of luck to the class of 2024 for their HSC exams. You got this!
    Let us know your thoughts on the HSC exams here
  • YOU can help the next generation of students in the community!
    Share your trial papers and notes on our Notes & Resources page
MedVision ad

Converting Degrees to Radians in VB.NET (1 Viewer)

Sentient_667

New Member
Joined
Mar 1, 2005
Messages
18
Location
Kellyville : Castle Hil, NSW
Gender
Male
HSC
2006
The piece of software I am required to design is a standalone scientific calculator, in Visual Basic.NET.

The requirements are that I add Sin, Cos and Tan functions. I've added all these buttons to the interface, but don't know what to do next.

My software teacher gave me some help, but I'm still unclear on how to add these buttons to the existing code. This is what I currently have:

Private Sub btnSin_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSin.Click
' Convert display to a double variable
Dim str As String = txtDisplay.Text
Dim num As Double = Convert.ToDouble(str)

' Convert the double variable to radians
Dim angleInRadians As Double = DegToRadians(num)

' Perform the calculation
' Display the answer
End Sub

Private Function DegToRadians(ByVal Value As Double) As Double
' Same to find the formula
I need to place the formula for converting degrees to radians in here.
End Function
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
The formula to use is radians = degrees * pi/180. The functions you want; tan, cos and sin and the constant pi can all be found in the Math class.

http://msdn.microsoft.com/
 
Joined
Jun 11, 2004
Messages
62
Gender
Male
HSC
2005
To elaborate on what sunny said, I thought I'd give this a quick go just to show you how it's done. Basically, I've just written the from radians to degrees and degrees to radians part for you. It's basically just an extension from what you had. Although, you can fix up the sine cosine and tangent bits for yourself. Good luck.

PHP:
    Private Sub btndeg2rad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndeg2rad.Click
        Dim str As String = txtDisplay.Text
        Dim num As Double = str
        ' Convert the double variable to radians
        Dim radians As Double
        Dim pi As Double
        pi = 3.14159265
        radians = num * pi / 180
        txtDisplay.Text = radians
    End Sub

    Private Sub btnrad2deg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnrad2deg.Click
        Dim str As String = txtDisplay.Text
        Dim radians As Double = str
        ' Convert the double variable to radians
        Dim num As Double
        Dim pi As Double
        pi = 3.14159265
        num = radians * 180 / pi
        txtDisplay.Text = num
    End Sub
 
Joined
Jun 11, 2004
Messages
62
Gender
Male
HSC
2005
ahahaha, saorry I havnt used this forum much until now. I'm glad it helped you out. Well, I feel like I've achieved something from this...even though I had forgotten about it and did it several months ago.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top