Results 1 to 5 of 5

Thread: [RESOLVED] Calculating Trigonometrical formulas

Threaded View

  1. #1

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Resolved [RESOLVED] Calculating Trigonometrical formulas

    This is a small calculator i'm writing. I just need help with VB.Net formulas for cotangent, secant, and cosecant.
    Given an angle (NumericUpDown1.Value), how would i complete this code?

    Code:
    Private Sub calculate()
        Select Case ComboBox1.SelectedIndex
            Case 0 ' sine(sin)
                Label3.Text = $"Math.Sin({NumericUpDown1.Value})"
                Label4.Text = Math.Sin(NumericUpDown1.Value).ToString
            Case 1 ' cosine(cos)
                Label3.Text = $"Math.Cos({NumericUpDown1.Value})"
                Label4.Text = Math.Cos(NumericUpDown1.Value).ToString
            Case 2 ' tangent(tan)
                Label3.Text = $"Math.Tan({NumericUpDown1.Value})"
                Label4.Text = Math.Tan(NumericUpDown1.Value).ToString
            Case 3 ' cotangent(cot)
                Label3.Text = $"1 / Math.Tan({NumericUpDown1.Value})"
                Label4.Text = 1 / Math.Tan(NumericUpDown1.Value).ToString '???
            Case 4 ' secant(sec)
                Label3.Text = ""
                Label4.Text = "" '???
            Case 5 ' cosecant(csc)
                Label3.Text = ""
                Label4.Text = "" '???
            Case Else ' -1
                Label3.Text = ""
                Label4.Text = ""
        End Select
    End Sub
    I'm just testing this now. Should the angle be given in Radians?
    Last edited by .paul.; May 21st, 2025 at 10:08 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width