How do I isolate the Fractional part of a number in Excel VB?

C

Cumulous

I'm a novice writing a VB program in Excel 2003, and I need to isolate
the fractional part of a number. In other words...

Input: 23.0891467
Output: 0.0891467


The only way I know of to do this is (Result = Input Mod 1). The
problem, is that while the Mod Operator works as a Worksheet Function - when
used as a VB Operator, Excel truncates the fractional portion of the result.
This, of course, makes it useless to me.


I need to know the best way to isolate the fractional portion of a
number (with maximum precision), that will work in Excel VB.

Any help will be appreciated! Thanks! :)
 
G

Guest

Dim input as double, output as double

Output=Input-int(Input)

Sub GetFraction()
Dim x As Double, y As Double
x = 23.0891467
y = x - Int(x)
Debug.Print y
End Sub

y=8.91467000000006E-02
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top