Skip to main content

^ operator

Table of contents
  1. Syntax
  2. Remarks
  3. Example

Used to raise a number to the power of an exponent.



The ^ operator syntax has these parts:

Part Description
result Required; any numeric variable.
number Required; any numeric expression.
exponent Required; any numeric expression.


A number can be negative only if exponent is an integer value. When more than one exponentiation is performed in a single expression, the ^ operator is evaluated as it is encountered from left to right.

Usually, the data type of result is a Double or a Variant containing a Double. However, if either number or exponent is a Null expression, result is Null.


This example uses the ^ operator to raise a number to the power of an exponent.

Dim MyValue
MyValue = 2 ^ 2    ' Returns 4.
MyValue = 3 ^ 3 ^ 3    ' Returns 19683.
MyValue = (-5) ^ 3    ' Returns -125.

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>