Wednesday, May 15, 2013

Math.Abs Function

Math.Abs Function

     Math.Abs() Function in VB.net 2008 is used to return the absolute value of a number.

Syntax:
    Math.Abs(number)
In the above syntax Number specifies the number to find the absolute value.
Example:
   Module Module1
    Sub Main()
        Console.WriteLine("Absolute Value of -5 is:: 
              " & Math.Abs(-5))
        Console.WriteLine("Absolute Value of 5.5 is:: 
              " & Math.Abs(5.5))
        Console.ReadLine()
    End Sub
   End Module
Output:
   Absolute Value of -5 is:: 5
   Absolute Value of 5.5 is:: 5.5
In the above example, the absolute value of '-5' is returned as '5' and the decimal value '5.5' returns the same value.

No comments:

Post a Comment