Changing format of fractions.

  • Thread starter Thread starter GregW
  • Start date Start date
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.
 
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)
 
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
 
Back
Top