Duc Posted March 5, 2001 Posted March 5, 2001 Hi everybody, Can some want know a technics script to convert a number to a text. Ex: 120 - Hundred and twenty I really appreciate that.
Vaughan Posted March 5, 2001 Posted March 5, 2001 This is a big job because it all has to be hard-coded in. Because it's hard-coded it will have a limit to the maximum number it will process. I think (not sure) that there is a calculation that does this at http://www.databasepros.com in the tips section or something.
BobWeaver Posted March 6, 2001 Posted March 6, 2001 I have done this for numbers up to 999,999,999. I found the best tradeoff between complexity and effort is to use a combination of calculations and a related file that holds the text version of numbers from 1 to 99. Break the number into groups of 3 digits. The first group is millions; the second group is thousands, and the last is units. Each of these is then broken into sub-groups consisting of the first digit, and the last two digits. This gives a total of 6 sub-groups. Create six relationships between the main file and the text lookup file based on each of these sub-group values. Each group is processed the same way. If a group is > 99 then lookup the text equivalent for the first digit and append "hundred" then lookup and concatenate the text for the last two digits. If the group value is zero, the resulting text should be an empty string. For the first group, if the string is not empty, append "million " For the second group, if the string is not empty, append "thousand " Finally, concatenate all strings together.
Duc Posted March 14, 2001 Author Posted March 14, 2001 Thanks a lot I found a lot of useful tip . quote: Originally posted by Vaughan: This is a big job because it all has to be hard-coded in. Because it's hard-coded it will have a limit to the maximum number it will process. I think (not sure) that there is a calculation that does this at http://www.databasepros.com in the tips section or something.
Recommended Posts
This topic is 8660 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 accountSign in
Already have an account? Sign in here.
Sign In Now