try using:
intResult = int(dblTime)
actually, you could use:
dbltime = dbltime - Int(dbltime)
instead of the "if" statement
but this would only work if dbltime is > 0
Paul
-----------------------------------------
"Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can." - John Wesley
-----------------------------------------
________________________________
From: Dawn Bleuel <dlbleuel@gmail.com>
To: ExcelVBA <ExcelVBA@yahoogroups.com>
Sent: Wed, February 29, 2012 2:17:54 PM
Subject: [ExcelVBA] How to convert double to integer
I need some help with something.
In VBA I have a snippet of code...
If dblTime > 1 Then
intResult = dblTime
dblTime = dblTime - intResult
End If
Works great if the value fed into dblTime is 1.454. The intResult = 1 and
the dblTime becomes .454
However, if the value of dblTime is 1.569 then the intResult becomes 2. I
need it to stay at 1. I'm sure there is some kind of convert function that
I'm not thinking of that will just extract the current whole number, but
I've come up blank.
Ideally, I want to end up with two variables splitting the whole number
from the decimal.
Thanks.
--
Dawn Bleuel
Word MVP
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar