Math.Sqrt Function in VB.NET

What is math.Sqrt function in VB.NET?

Explanation

Math.Sqrt Function

Math.Sqrt in VB.NET is a mathematical function that is used to return the square root of a given number.
Syntax:

Math.Sqrt(Number)

In the above syntax Number is the number whose square root is to be returned.
Example:

Module Module1
Sub Main()
Console.WriteLine("Square root of 4 is:: " & Math.Sqrt(4))
Console.WriteLine("Square root of -4 is:: " & Math.Sqrt(-4))
Console.ReadLine()
End Sub
End Module
Result:

Square root of 4 is:: 2
Square root of -4 is:: NaN

In the above example, the Math.Sqrt mathematical function is used to get the squareroot of a '4'. For a negative number 'NaN' is returned.

Visual Basic Tutorial


Ask Questions

Ask Question