Skip to Content
VB.NET Language in a Nutshell, Second Edition
book

VB.NET Language in a Nutshell, Second Edition

by Steven Roman PhD, Ron Petrusha, Paul Lomax
April 2002
Intermediate to advanced
688 pages
19h 51m
English
O'Reilly Media, Inc.
Content preview from VB.NET Language in a Nutshell, Second Edition

Name

Int Function

Class

Microsoft.VisualBasic.Conversion

Syntax

Int(number)
number (required; any valid numeric data type)

The number to be processed

Return Value

Returns a value of the data type passed to it

Description

Returns the integer portion of a number

Rules at a Glance

  • The fractional part of number is removed, and the resulting integer value is returned. Int does not round number to the nearest whole number. For example, Int(100.9) returns 100.

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

Programming Tips and Gotchas

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

  • Don’t confuse the Int function with CInt. CInt casts the number passed to it as an Integer data type, whereas Int returns the same data type that was passed to it.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596003080Supplemental ContentCatalog PageErrata