VB: Round up decimal value by truncate floating point

So I was searching for a method to get the integer value from a floating number but found a quick workaround towards the problem. Below is what I have come up with:

function convertInt(value as double) as integer
  dim arrayNo
  arrayNo=Split(value,”.”)
  convertInt=arrayNo(0)
end function

I believe the above function code is self explainatory. Anyone have a better way or suggestion?

Written by admin on August 21st, 2007 with 2 comments.
Read more articles on Personal and Programming.

Related articles

2 comments

Read the comments left by other users below, or:

Get your own gravatar by visiting gravatar.com Andrew
#1. February 23rd, 2009, at 11:04 PM.

(Assumes VB6 or VBA)

Any reason you would not use the native cint/int/fix functions?

Get your own gravatar by visiting gravatar.com admin
#2. March 11th, 2009, at 11:55 AM.

Hie Andrew,
Thank you. I did not try the int/fix function out instead of cint in which cint actually rounds up the floating value.

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .