Visual Basic Powering a Number

You can use the Pow() method of the Math class to get the specified power of a number in the Visual Basic programming language.

This method takes 2 parameters. The first parameter is the number itself (base), and the second parameter is the force to be taken (power).

Parameters are of type double. Likewise, the method returns a value of type double.

Let's examine the example below..

Module ModuleTest Sub Main() Dim num1 As Double = 5 Dim num2 As Double = 3 Dim pow As Double = Math.Pow(num1, num2) Console.WriteLine(pow) Console.ReadLine() End Sub End Module

In the example, the number 5 to the 3rd power is taken. The result will return 125.



You May Interest

Visual Basic Get Now

Visual Basic How To Find The Average Of 10 Numbers Using A While ...

Visual Basic String Making Lowercase

Visual Basic Using String ToCharArray

Visual Basic Finding the Operating System Username