View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Returning just the integer portion of a number

On Thu, 7 Jun 2007 10:42:16 -0400, "George Burdell"
wrote:

I think what is happening is that anyNum /0.1 is actually
483.99999999999, thus the value of 483 as the answer. The only solution
I've come up with is to join anyNum with a text string ("x"), find the
decimal in the text string, extract the number between the "x" and the
decimal, and assign it to I.


You're correct, although the number is a bit less that 483.999999999999999.

One thought:

Sub test()
Dim anyNum
Dim I As Integer
anyNum = 48.4
anyNum = CDec(anyNum / 0.1)
I = Int(anyNum)
Debug.Print I
End Sub
--ron