Visual Basic Explorer
Visual Basic Explorer
 Navigation
 Home


 Coding
 Source Code

 FAQ Center

 VB Tips

 Downloads

 ToolBox

 Tutorials

 VB Games

 VB News

 VB Award

 VB Forums



 Affiliates
 Planet Source Code

 Rent a Coder

 DirectX4VB


 Misc
 Search

 Feedback

 Advertise

 About


Need to hire
a VB coder?

Please support our sponsor:

 Home 
 Site Map 
 Forums 
 News 
 Feedback 

 

'Conversion Functions to Truncate Fractions?

 
Q. Does anyone know a function that would convert a currency-type number like
1.9833 or something to an integer by simply truncating the factional part:
.9833? It seems the int, fix and such functions only round them to the closest
number, but I want to keep just integer to the left of the decimal point, with
no rounding.

 
Q. Keywords: CInt, Int, Fix functions.

 
CInt will round your number to an integer. Int and Fix will truncate the digits
following the decimal point. The following is from the VB help file:

 
Int and Fix return a value of the type passed to it containing the integer
portion of a number.

 
Both Int and Fix remove the fractional part of number and return the resulting
integer value.

 
The difference between Int and Fix is that if number is negative, Int returns
the first negative integer less than or equal to number, whereas Fix returns the
first negative integer greater than or equal to number. For example, Int
converts -8.4 to -9, and Fix converts -8.4 to -8.

 
Thanks to: Brad, Rich, Dennis


Downloads

In IE right-click and select 'Save Target As...' or in Netscape right-click and select 'Save Link As...'

 

View Plain Text View Plain Text
Download Demo Project Not Available
View Code Online Not Available





Home | About | What's New | Source Code | FAQ | Tips & Tricks | Downloads | ToolBox | Tutorials | Game Programming | VB Award | Search | VB Forums | Feedback | VBNews | Copyright & Disclaimer | Advertise | Privacy Policy |

Quick searches: Site Search | Advanced Site Search 

Copyright 2002 by Exhedra Solutions, Inc.
By using this site you agree to its terms and conditions
VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc.