Jump to content

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. smile.gif

-Brent

Link to comment
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!

Link to comment
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.