^ Operator

See Also1PHVSEN              Example4HPEWV>Low

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


result = number ^ exponent


The number and exponent operands can be any numeric expression71RISN.  However, the number operand 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 type3GYXY7 of result is a Double or a Variant8PHEAW3 (VarType7A68ZTZ 5).  However, if either number or exponent is a Null1DDW7C0 expression, result is also a Null.

See Also

Arithmetic OperatorsSH0K1B

Comparison OperatorsNRJZ1K

Concatenation Operators2MYTW1K

Logical Operators1CQVUTN

Operator Precedence23082A9

Other Operators2HA580P

VarType FunctionXRZH1Y

^ Operator Example

The example squares (n^2) a user supplied number.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.


Sub Form_Click ()

   Dim N As Double, Result As Double     ' Declare variables.

   N = InputBox("Enter a number.")       ' Get number.

   Result = N ^ 2                        ' Square number.

   MsgBox N & " squared is " & Result    ' Display result.

End Sub