Fix Function In VB.NET
Fix Function In VB.NET
Explanation
Fix Function
Fix Function in Visual Basic.net 2008 is used to returns the integer part of the given number.
But if the number is negative it returns a negative number greater than or equal to the number.
Syntax:
Fix(Number)
In the above syntax
Number specifies the number to return the integer part alone.
Example:
Module Module1
Sub Main()
Console.WriteLine("Integer part of 2.27 is: " & Fix(2.27))
Console.WriteLine("Integer part of 0.23 is: " & Fix(0.23))
Console.WriteLine("Integer part of -1.2 is: " & Fix(-1.2))
Console.ReadLine()
End Sub
End Module
Result:
Integer part of 2.27 is: 2
Integer part of 0.23 is: 0
Integer part of -1.2 is: -1
In the above Fix Function example, the integer part of the negative integer '-1.2' is
returns the higher value of '-1'. This is the difference between Fix and Int functions.