In this article, i will introduce again some function in VB.NET regarding the Math Functions, this is Math.Pow().
Math.Pow() Function in vb.net computes a number that has an exponent.It returns a specified number raised to the specified power.
So, 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
TextBox1 and
TextBox2 then leave it as blank.
TextBox1 will be used as an input for a number and
TextBox2 will be used as an input for the exponent. Now, add a Button named
Button1 to compute the exponential number. You must design your layout like this:
3. Now, put this code in Button1_Click. This will compute your exponential number.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num1 As Integer, expo As Integer
Dim result As Integer
num1
= Val(TextBox1
.Text) expo
= Val(TextBox2
.Text) result = Math.Pow(num1, expo)
MessageBox.Show(num1 & " to the power of " & expo & " is" & " " & result)
End Sub
In this code, we initialized
Dim num1 As Integer, expo As Integer
Dim result As Integer
num1 holds the value of TextBox1 as we input it our main number,
expo holds the value of TextBox2 as we declare it as our exponent, and the
result variable holds the answer to the exponential number. We used the formula
Math.Pow(num1, expo)
to have the result pass through the variable
result. Then it will get the answer in num1 and the expo as our exponent. Then it will display
num1 & " to the power of " & expo & " is" & " " & result.
Output:
Download the source code below and try it! :)
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]
Visit and like my page on Facebook at: Bermz ISware Solutions
Subscribe at my YouTube Channel at: SerBermz
Visit and like my page on Facebook at:
https://www.facebook.com/BermzISware