Fix Function


Fix Function

Class

Microsoft.VisualBasic.Conversion

Syntax

     Dim result As type = Fix(number) 


number (required; any numeric expression)

The number to be processed. Uses one of the following data types: Double, Single, Decimal, Integer, Long, Short, or Object. If Object is used, the value must evaluate to a number. The return data type always matches the data type of number.

Description

The Fix function returns the integer portion of a number, with any fractional part truncated.

Usage at a Glance

  • Fix truncates numbers; it does not round. For example, Fix(100.9) returns 100.

  • Even for negative source values, Fix simply truncates the fractional portion. For example, Fix(-10.9) returns -10.

  • A source of Nothing returns Nothing.

  • The Int and Fix functions work identically with positive numbers. However, for negative numbers, Fix returns the first negative integer greater than the source value, while Int returns the first negative integer less than that value. For example, Fix(-10.1) returns -10, while Int(-10.1) returns -11.

See Also

Int Function, Round Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net