Hello,

I have written a program that uses trig functions and the results are in Radians. I would like to show the results in Degrees and have found a Method named RadianToDegree but am having difficulty applying it.

Can someone offer help with this, or perhaps a different way to accomplish what I need??

Thanks,

Jim

What code are you using? The formula is pretty simple.

radians * 180.0 / PI

Yes, thanks for that. I am quite familiar with the formula. I am very new to programming and trying to learn the ins-and-outs of using the many built in solutions for problem solving.

The program I am writing will have many instances of trig functions and therefore will require many instances of converting if I apply the formula. Instead I was hoping for some built in function that would universally do the conversion for me.

Thanks,

Jim

k, you said that you're having trouble applying a function you've already found. If you post the code that uses it, I can try to help out on that end. I don't think there's a function that does this built into .NET, but it's trivial to write.

As Inanna says:

Imports System.Math

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = CStr(RadianToDegree(Sin(0.2345)))
    End Sub

    Public Function RadianToDegree(ByVal radians As Single) As Single
        Return radians * 180.0 / PI
    End Function

End Class

What problems are you having? It works okay for me.

Thanks Wayne - That's pretty much the way I'm trying to use RadianToDegree, but whenever I try to apply it to my program it gets a blue underline with a statement saying

Name 'RadianToDegree' is not declared.

I'm too new to this to fully understand how to deal with that message.

Jim

You aren't defining the function or it's not visible from where you're calling it. Make sure that the function actually exists and that you're spelling the name right. That's usually my problem. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.