The VBA Sqr function returns the square root of a supplied number.
The syntax of the function is:
Where the Number argument is a positive real number that you want the square root of.
' Find the square root of the numbers 6.25 and 0
Dim res1 As Double
Dim res2 As Double
res1 = Sqr( 6.25 )
' Now, res1 = 2.5 and res2 = 0
res2 = Sqr( 0 ) |
In the above VBA code:
If you supply a negative Number argument to the VBA Sqr function, you will get the error:
If the Sqr function is supplied with a value that cannot be interpreted as a number, it will return the error: