Sqr Function

See Also370JGX5              ExampleGUA9FM>Low

Returns the square root of a number.

Syntax

Sqr(number)

Remarks

The argument number can be any valid numeric expression71RISN that results in a value greater than or equal to 0.

The return type of Sqr function is Double.


See Also

Math FunctionsEK0VY1


Sqr Function Example

The example uses Sqr to calculate the square root of 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 Msg, Number                       ' Declare variables.

   Msg = "Enter a non-negative number."

   Number = InputBox(Msg)                ' Get user input.

   If Number < 0 Then

      Msg = "Cannot determine the square root of a negative number."

   Else

      Msg = "The square root of " & Number & " is "

      Msg = Msg & Sqr(Number) & "."

   End If

   MsgBox Msg                            ' Display results.

End Sub