473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to set 0,1 as 0.1 on Sine and Cos function ?

3
Hello,

When I use the Math.Cos and Math.Sin function I get wrong result because it get the value as 0,1 instead of 0.1.
Here is an example

14,9896229 * sin(0,525) = 14
14,9896229 * cos(0,525) = 0

(those values are imputed automatically)

BUT

14.9896229 * sin (0.525) = 12,9708795712695
14.9896229 * cos(0.525) = 7,51299393263617

(those values I edited then manually while running the program)

Here is my code :
Expand|Select|Wrap|Line Numbers
  1. Public Class AdUL
  2.  
  3.     Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  4.  Handles TextBox1.TextChanged
  5.  
  6.         TextBox3.Text = Val(TextBox1.Text) * 299792458 * 0.00000001
  7.         TextBox4.Text = Val(TextBox2.Text) * (Math.PI / 180)
  8.  
  9.     End Sub
  10.  
  11.     Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  12.  Handles TextBox2.TextChanged
  13.  
  14.         TextBox3.Text = Val(TextBox1.Text) * 299792458 * 0.00000001
  15.         TextBox4.Text = Val(TextBox2.Text) * (Math.PI / 180)
  16.  
  17.     End Sub
  18.  
  19.     Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  20.  Handles TextBox3.TextChanged
  21.  
  22.         Dim R As Decimal = Val(TextBox3.Text)
  23.         Dim a As Decimal = Val(TextBox4.Text)
  24.         TextBox5.Text = R * Math.Cos(a)
  25.         TextBox6.Text = R * Math.Sin(a)
  26.  
  27.     End Sub
  28.  
  29.     Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  30.      Handles TextBox4.TextChanged
  31.  
  32.         Dim R As Decimal = Val(TextBox3.Text)
  33.         Dim a As Decimal = Val(TextBox4.Text)
  34.         TextBox5.Text = R * Math.Cos(a)
  35.         TextBox6.Text = R * Math.Sin(a)
  36.  
  37.     End Sub
  38.  
  39.  
  40. End Class
Note: I changed the decimal, interger, single and may more ... I get the same result ...
Note2: I use Visual Basic from Visual Studio 2008

Note3: I need results like the second example

Can some help me ?

Thank you
Apr 27 '15 #1
1 1652
Seth Schrock
2,965 Expert 2GB
Try using the CDec() function in your TextBox4 TextChanged event instead of the Val() function. Like this:
Expand|Select|Wrap|Line Numbers
  1. Dim R As Decimal = CDec(TextBox3.Text)
  2. Dim a As Decimal = CDec(TextBox4.Text)
  3. TextBox5.Text = (R * Math.Cos(a)).ToString()
  4. TextBox6.Text = (R * Math.Sin(a)).ToString()
  5.  
May 5 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

143
by: suri | last post by:
Hello I downloaded glibc and tried looking for the code that implements the sine function i couldnt find the file. i went to the math directory and found math.h.. i guess that needs to be...
9
by: Water Cooler v2 | last post by:
What is the inverse of the sine function? I've been pulling my hair and I have no clue nor memory of how to go about solving this little expression: sine-1 (read sine inverse) of (1-(x/y)) An...
10
by: Owkmann | last post by:
Can someone give me a rough idea how a value is obtained for a trigonometric function like Math.Sin? What is the algorithm? I'm finding that putting a large number in this function ( > 8000 )...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.