# Changing text fractions into numbers

This topic is 6430 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

I'm creating a cookbook DB for my wife. Easy enough. I told her that any fractional quantities will have to be entered as a decimal number. She didn't like that idea, saying that it's easier and less confusing to enter and see "3/4" rather than .75 Ok, easy enough - or so I thought. I would prefer to have the quantity as an indexable numberic value, so that if I want to double the recipe (for example), the calculations will be easy to deal with, and for other programming reasons.

I tried to change the quantity as a text field, and use the texttonum & numtotext in any calculations. That pesky "/" was getting in the way, though. I didn't want to separate out a field for the numerator and another field for the denominator, because not all quantities are going to be fractional.

I suppose that there are a few different ways to tackle this problem (as with any programming problem). I suppose I could figure this out eventually on my own. But I figure it's much easier asking everyone here and having an immediate result, rather than keep banging my head against the wall. I've done enough of that at work, and I'm sure not going to continue at home! Plus I'm sure I'm not the only person out there that has tried this already.

Any ideas will be greatly appreciated.

-Brent

##### Share on other sites

Maybe:

Left(quantity; 1) / Right(quantity; 1) ?

##### Share on other sites

Hi Brent,

Here are a couple of files that show how to do this.

Fractions to Decimals By: John Mark Osborne URL:

Number to Fraction By: John Mark Osborne URL:

HTH

Lee

##### Share on other sites

Oh yea Detlev Sometimes I like to complicate things WAY too much. That will be perfect - as long as the numberator and/or the denominator is only one number long (ex. 1/8) It would be easy enough to make a case statement to determine how many characters are before/after the slash to make other arrangements for the left/right functions.

To anyone reading this - recipies normally won't have measurements smaller that X/8. So for all practical purposes, what Detlev has come up with will be great for what I'm doing. I won't need to worry about the 16th measurements.

Now it's on to figuring out how to convert these number to metric....

Thanks Detlev and Lee!

##### Share on other sites

This topic is 6430 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account