Solved

Converting numerical amounts to Text-based messages

Posted on 2000-04-21
9
245 Views
Last Modified: 2010-04-04
I'm building a project and i need code to transform numerical amounts (i.e.125.50 dollars) to text-based messages (i.e. one hundred and 25 dollars and fifty cents). Is there any possible way to do this in code?.
0
Comment
Question by:LatinFriend_M
9 Comments
 

Author Comment

by:LatinFriend_M
ID: 2738749
Adjusted points from 100 to 150
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2739064
Sorry, EE prohibits members to ask assignment Q's and experts to answer them.

If you have specific problems with how to write the code then that is a perfectly reasonable question to ask, but to just plain ask for the code for your assignment is not.

Sorry,

Raymmond.
0
 

Author Comment

by:LatinFriend_M
ID: 2739128
Edited text of question.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 3

Expert Comment

by:f15iaf
ID: 2739556
you need to give more points for this code
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2739595
hi LatinFriend_M,

get the fre component-library vglib at

http://www.tsinet.ru/~vg/


it contains this component:
TMoneyString : TMoneyString is high-customizable component that converts
numbers to verbal representation.

hope this helps

meikl
0
 

Author Comment

by:LatinFriend_M
ID: 2740611
i really aprecciate your help kretzschmar, but i would like to do my best and try to code myself this rutine. I will keep the adress you gave me just in case, but for now, i will keep looking for the basics for this rutine. Thanks anyway kretzschmar. f15iaf, i appreciate your comment. I'm a new one in this site and i would like to know how much points my question deserve. Thanks for your comment.
0
 

Expert Comment

by:lgmm
ID: 2744225
in this page you can find a component that make the changes from numeric to letters

this is a great page

http://delphi.icm.edu.pl/
0
 

Author Comment

by:LatinFriend_M
ID: 2745801
lgmm

I appreciate your help, but i was looking in the site you recommended me and i couldn't find the component you told me. Perhaps you can tell me where to look for in the site (i use delphi 3). However, i'm not looking for a component, i'm looking for "clues" to begin my own unit. If in this site is a explanation of the component you told me or pieces of the code used to create it, i will take your answer for good!!. Please let me know where i can find this component.
0
 
LVL 1

Accepted Solution

by:
veeramani earned 150 total points
ID: 2746294
Hi Latinfriend,
                here is the answer for you,but partially,you update it to speak the cents.
Regards,

veeramani
 
If u want to convert no.s into words use this function
ie 2567 - Two thousand Five hundred sixty seven
 
str := notowords(2567) ;
Max Limit - 1,999,999,999. (Integer limit, I can't help it)
 
Note : If u get any bugs in this, let me know.
 
Function NotoWords(Money : Integer): string;
var
   DivisnArr : array [1..6] of integer ;
   HunThuArr : array [1..4] of string ;
   TenNinArr : array [1..9] of string ;
   TeennoArr : array [1..9] of string ;
   SingleArr : array [1..9] of string ;
 
   Remainder,Quotient, I : integer ;
   HundredAdd, TempStr : string ;
 
begin
 
   DivisnArr[1] := 1000000000 ;
   DivisnArr[2] := 1000000 ;
   DivisnArr[3] := 1000 ;
   DivisnArr[4] := 100 ;
   DivisnArr[5] := 10 ;
   DivisnArr[6] := 1 ;
 
   HunThuarr[1] := 'Billion' ;
   HunThuarr[2] := 'Million' ;
   HunThuarr[3] := 'Thousand' ;
   HunThuarr[4] := 'Hundred' ;
 
   TenNinArr[1] := 'Ten' ;
   TenNinArr[2] := 'Twenty' ;
   TenNinArr[3] := 'Thirty' ;
   TenNinArr[4] := 'Fourty' ;
   TenNinArr[5] := 'Fifty' ;
   TenNinArr[6] := 'Sixty' ;
   TenNinArr[7] := 'Seventy' ;
   TenNinArr[8] := 'Eighty' ;
   TenNinArr[9] := 'Ninty' ;
 
   TeennoArr[1] := 'Eleven' ;
   TeennoArr[2] := 'Twelve' ;
   TeennoArr[3] := 'Thirteen' ;
   TeennoArr[4] := 'Fourteen' ;
   TeennoArr[5] := 'Fifteen' ;
   TeennoArr[6] := 'Sixteen' ;
   TeennoArr[7] := 'Seventeen' ;
   TeennoArr[8] := 'Eighteen' ;
   TeennoArr[9] := 'Ninteen' ;
 
   SingleArr[1] := 'One' ;
   SingleArr[2] := 'Two' ;
   SingleArr[3] := 'Three' ;
   SingleArr[4] := 'Four' ;
   SingleArr[5] := 'Five' ;
   SingleArr[6] := 'Six' ;
   SingleArr[7] := 'Seven' ;
   SingleArr[8] := 'Eight' ;
   SingleArr[9] := 'Nine' ;
 
   if money=0 then exit ;
   for i:=1 to 6 do
   begin
      if i<5 then
      begin
         quotient := Money div divisnarr[i] ;
         Remainder := Money mod divisnarr[i] ;
      end
      else
         quotient := remainder ;
 
      if quotient>0 then
      begin
         if quotient>99 then
         begin
             HundredAdd := SingleArr[quotient div 100] + ' '+ HunThuarr[4] + ' ';
             quotient := quotient mod 100 ;
         end ;
         if quotient > 0 then
         begin
            if (quotient mod 10)=0 then
            begin
               Tempstr := TenNinArr[quotient div 10] ;
            end
            else if (quotient > 20) then
            begin
               tempstr := TenNinArr[quotient div 10] + ' ' + SingleArr[quotient mod 10] ;
            end
            else if (quotient > 10) and (quotient < 20) then
            begin
               tempstr := TeenNoArr[quotient-10] ;
            end
            else if quotient<10 then
            begin
               tempstr := SingleArr[quotient] ;
            end ;
         end ;
         if i<5 then
            NotoWords := hundredadd + tempstr +' '+ HunThuarr[i] + ' '+  notowords(remainder)
         else
            NotoWords := tempstr + ' ';
         exit ;
      end ;
   end ;
 
end ;
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 157
PHP preg_replace code convert to Delphi 14 55
Tidtcpserver listening on multiports? 1 27
Twebbrowser add css to the header 3 25
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question