See Also Example
Used to raise a number to the power of an exponent.
Syntax
result = number ^ exponent
Remarks
The number and exponent operands can be any numeric expression 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 type However, if either number or exponent is a Null expression, result is also a Null.
Arithmetic Operators
Comparison Operators
Concatenation Operators
Logical Operators
Operator Precedence
Other Operators
VarType Function
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