Math Functions in VB.NET
Submitted by donbermoy on Thursday, May 22, 2014 - 10:49.
Today, I will teach you how to create a program that has math functions in Visual Basic.NET. Here you will learn about Abs, Log, Round, Sin, Cos, and Tan Function.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add two textboxes named txtNum for your inputted number and txtOut for the output. Insert 6 Buttons named btnAbs for Absolute Value, btnLog for Logarithm, btnRound for Rounding off, btnSin for finding the sine of an angle, btnCos for the Cosine of an angle, and btnTan for the Tangent of the angle. You must design your interface like this:
3. In your btnAbs for Absolute Value, copy this code below. This Abs function will return absolute value of our inputted number, means even if we input negative number, the output will be positive.
Output:
6. In your btnSin for finding the sine value of the inputted number (angle), copy this code below. This Sin function will return the specifying the sine of an angle as our inputted number.
Output:
4. In your btnLog for finding the Logarithm of a number, copy this code below. This Log function will return the logarithmic value of our inputted number.
Output:
5. In your btnRound for rounding off a number, copy this code below. This Round function will return the inputted number to nearest the specified value. It means that if the nearest value after the decimal point is 5, then it will increase by 1 the whole number. Otherwise, the whole number will be the same.
- Private Sub btnRound_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRound.Click
- End Sub
Output:
7. In your btnCos for finding the cosine value of the inputted number (angle), copy this code below. This Cosine function will return the specifying the cosine of an angle as our inputted number.
Output:
7. In your btnTan for finding the tangent value of the inputted number (angle), copy this code below. This Tan function will return the specifying the tangent of an angle as our inputted number.
Output:
Hope this helps! :)
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
Add new comment
- 1266 views