Example:

  1. Sub Form_Click ()

    1. Dim Msg, Number          ' Declare variables.

      Msg = "Enter a non-negative number."

      Number = InputBox(Msg)          ' Get user input.

      If Number < 0 Then

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

      Else

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

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

      End If

      MsgBox Msg           ' Display results.

    End Sub