Compute Exponential Number using VB.Net

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: design 3. Now, put this code in Button1_Click. This will compute your exponential number.
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim num1 As Integer, expo As Integer
  3. Dim result As Integer
  4. num1 = Val(TextBox1.Text)
  5. expo = Val(TextBox2.Text)
  6. result = Math.Pow(num1, expo)
  7.  
  8. MessageBox.Show(num1 & " to the power of " & expo & " is" & " " & result)
  9. End Sub
In this code, we initialized
  1. Dim num1 As Integer, expo As Integer
  2. 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:

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

Add new comment