Int Function


Int Function

Class

Microsoft.VisualBasic.Conversion

Syntax

     Dim result As type = Int(number) 


number (required; any numeric expression)

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

Description

The Int function returns the whole number that is less than or equal to the source value.

Usage at a Glance

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

  • If the source value is negative, Int returns the first negative integer less than or equal to that value. For example, Int(-10.1) returns -11.

  • 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.

  • Int is not the same as the CInt function. CInt casts the number passed to it as an Integer data type, while Int returns the same data type that was passed to it.

See Also

CInt Function, Fix 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