Changing format of fractions.

G

GregW

Help,

I have been unable to convert imported fractions in the
format 4 5/8, 4 11/16, 11 13/16 etc. to a decimal.

Any ideas?


Thanks in advance.
 
S

Steve Schapel

Greg,

I can't think of any more elegant way, than using string manipulation
functions as follows...

TheDecimal: Left([TheFraction],InStr([TheFraction],"
")-1)+Mid([TheFraction],InStr([TheFraction],"
")+1,Len([TheFraction])-InStr([TheFraction],"/"))/Mid([TheFraction],InStr([TheFraction],"/")+1)
 
T

Tim Ferguson

I have been unable to convert imported fractions in the
format 4 5/8, 4 11/16, 11 13/16 etc. to a decimal.

..... = Eval(Replace(strFraction, " ", "+"))

which converts "4 5/8" to "4+5/8" which evalutes to 4.625 or whatever.

Of course, there is no protection from rubbish strings ("4 5/8") so you'd
need to validate them first.

Hope that helps


Tim F
 

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