+ Reply to Thread
Results 1 to 9 of 9

trigonometric functions wont work

  1. #1
    Registered User
    Join Date
    03-08-2015
    Location
    Germany
    MS-Off Ver
    2013
    Posts
    4

    trigonometric functions wont work

    hi, i cant get the trigonometric functions to work... i tried almost everything but it seems that i cant even get the most simpliest things to work... :/
    i need sin, cos, tan, aswell as the inverse functions arcsin, arccos and arctan, the numbers are typed into a textbox.

    the sin, cos and tan functions are already working

    Private Sub sin_Click()
    TextBox = Math.sin(Val(TextBox))
    End Sub

    but i only get the results in radians and i want them in degrees, too. i tried the convertion with 180/pi but that seems wrong (other results in windows calc for example)

    a much bigger problem is that inverse sin and cos arent working at all while inverse tan works perfectly (even radians to degrees)

    i tried the worksheetfunctions and own functions like arcsin(x) as double but i dont get any results if the number isnt negative and the worksheetfunctions dont work at all...

    can anyone help me, please?

  2. #2
    Registered User
    Join Date
    01-09-2015
    Location
    Turket
    MS-Off Ver
    2013
    Posts
    64

    Re: trigonometric functions wont work

    I cannot open my excel, but I guess you should write like dsin or degsin . You can try this.

  3. #3
    Registered User
    Join Date
    03-08-2015
    Location
    Germany
    MS-Off Ver
    2013
    Posts
    4

    Re: trigonometric functions wont work

    you mean like Math.dsin or Math.degsin? no this doesnt work. :/

  4. #4
    Registered User
    Join Date
    01-09-2015
    Location
    Turket
    MS-Off Ver
    2013
    Posts
    64

    Re: trigonometric functions wont work

    Normally, =sin(30) gives you result as radians.
    =sin(degree(30)) gives you result as degree. You can try it for VBA

    Please Login or Register  to view this content.
    I guess, It should be like this.

  5. #5
    Registered User
    Join Date
    03-08-2015
    Location
    Germany
    MS-Off Ver
    2013
    Posts
    4

    Re: trigonometric functions wont work

    nop, just shows an error

    what about other worksheet functions? how do i use them without an error ?

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: trigonometric functions wont work

    Try

    Please Login or Register  to view this content.
    Or

    Please Login or Register  to view this content.
    Or you could use WorksheetFunction.Degrees and WorksheetFunction.Radians
    Last edited by mikerickson; 03-08-2015 at 12:35 PM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  7. #7
    Registered User
    Join Date
    03-08-2015
    Location
    Germany
    MS-Off Ver
    2013
    Posts
    4

    Re: trigonometric functions wont work

    option one works perfect for me, thanks!

    i tried WorksheetFunction.Degrees and WorksheetFunction.Radians but it does the same as multiplying it with 180/pi

    but these functions are useless without the inverse functions :/

    it seems that worksheetfunction or an equation with Math.atn is the only possible option for me but i always get errors somewhere.
    TextBox = WorksheetFunction.asin(Val(TextBox)) works with positive numbers but not with negative ones, same with WorksheetFunction.acos

    can anyone look into this aswell, please?
    Last edited by 2ndHype; 03-08-2015 at 01:06 PM.

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,379

    Re: trigonometric functions wont work

    Can you provide some sample inputs and outputs?

    Here's a quick spreadsheet I put together to test the trig function. Everything seems to work as expected, both when using the functions in the spreadsheet and when calling the functions from VBA. I think we will need some examples where you get the wrong or unexpected result to help debug this.
    Attached Files Attached Files
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: trigonometric functions wont work

    Quote Originally Posted by 2ndHype View Post
    ...
    TextBox = WorksheetFunction.asin(Val(TextBox)) works with positive numbers but not with negative ones, same with WorksheetFunction.acos

    can anyone look into this aswell, please?
    This worked perfectly for me. (I didn't add any handling to deal with ABS (Textbox1.Text) being larger than 1).
    It did negative inputs fine. (note that cos(-x)=cos(x), so Acos(x)= Acos(-x))

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Sumif+Large Functions Wont Work Together
    By mkeys4 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-16-2013, 10:23 AM
  2. [SOLVED] How do I graph trigonometric functions?
    By dkramb in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-06-2006, 09:20 PM
  3. [SOLVED] how to use trigonometric functions in Excel?
    By JohnP in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-24-2006, 10:45 PM
  4. Why wont it work?
    By Bobby in forum Excel General
    Replies: 6
    Last Post: 12-01-2005, 08:55 PM
  5. [SOLVED] Anyone know why this wont work?
    By Mark Stephens in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2005, 02:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1