简体   繁体   English

在Visual Basic中制作科学计算器

[英]Making Scientific Calculator in visual basic

这链接到我的应用程序表单的图像


I want to make program in visual basic that can calculate cosine of any angle in degrees such that when I enter the angle in the textbox labeled "angle text box" and hit the "cos" button it well show the result in "result text box". 我想在Visual Basic中制作程序,该程序可以计算以度为单位的任意角度的余弦值,这样,当我在标有“角度文本框”的文本框中输入角度并单击“ cos”按钮时,它会在“结果文本框”中很好地显示结果”。 This code give the cosine in radians. 此代码以弧度表示余弦。 I need it in degrees 我需要度数

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    TextBox2.Text = Math.Cos(TextBox1.Text)
End Sub

The .Net framework's Math namespace trigonometric functions expect to have angles expressed as radians, not degrees. .Net框架的Math名称空间三角函数希望将角度表示为弧度,而不是度。

Before calling Math.Cos() , convert your input from degrees to radians, like this: 在调用Math.Cos()之前,将输入从度转换为弧度,如下所示:

Textbox2.Text = Math.Cos(Textbox1.Text * (Math.PI / 180.0)); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM