Code converting numbers into words

Hi, there,

I remember that I came across some objects which can convert a number into
words.
For example, 85 is converted to English words "Eighty five", but I can't
remember 
it now. Does anyone know of any such code?

Please email me regarding any information. Thanks.

Ming

---== Posted via the PFCGuide Web Newsreader ==---
http://www.pfcguide.com/_newsgroups/group_list.asp
0
Ming
4/13/2000 9:53:12 AM
sybase.powerbuilder.general 62418 articles. 17 followers. Follow

2 Replies
709 Views

Similar Articles

[PageSpeed] 33

Hi!

Try this little snippet I made just for you.:-)))

Any comments and suggestions are most welcome.

//**************************************************************************
********
// Function Name: of_NumToWords
// Purpose           : Convert number into words
// Author              : Jun Miano  E-Mail :  Jun@HCDC.Fapenet.org
// Revised Date : April 13,2000
// Usage             : s_RetVal = of_NumToWords("123,456,789.00")
//**************************************************************************
********

// Comments     : Self - Explanatory

// Any revision  please let me know.


//***********************
Int   i_Len,     &
       i_Ctr,     &
       i_Number,  &
       i_Hundreds,&
       i_Tens,    &
       i_Ones,    &
       i_Words

String s_Amount,   &
       s_Number,   &
       s_Literal,  &
       s_Remain,   &
       s_ToProcess,&
       s_RetVal

String s_Tens[9], s_Ones[19], s_HowMuch[10], s_Words[10]

s_Literal = ''
s_Words[1] = ' '

s_Amount = as_Amount

IF Integer(s_Amount) = 0 THEN RETURN 'Zero'

i_Len = Len(s_Amount) - 3

IF i_Len = 3 THEN RETURN Right(s_Amount,2) + '/100'

s_Ones[1]  = 'One '
s_Ones[2]  = 'Two '
s_Ones[3]  = 'Three '
s_Ones[4]  = 'Four '
s_Ones[5]  = 'Five '
s_Ones[6]  = 'Six '
s_Ones[7]  = 'Seven '
s_Ones[8]  = 'Eight '
s_Ones[9]  = 'Nine '
s_Ones[10] = 'Ten '
s_Ones[11] = 'Eleven '
s_Ones[12] = 'Twelve '
s_Ones[13] = 'Thirteen '
s_Ones[14] = 'Fourteen '
s_Ones[15] = 'Fifteen '
s_Ones[16] = 'Sixteen '
s_Ones[17] = 'Seventeen '
s_Ones[18] = 'Eighteen '
s_Ones[19] = 'Nineteen '

s_Tens[1]  = ' '
s_Tens[2]  = 'Twenty '
s_Tens[3]  = 'Thirty '
s_Tens[4]  = 'Fourty '
s_Tens[5]  = 'Fifty '
s_Tens[6]  = 'Sixty '
s_Tens[7]  = 'Seventy '
s_Tens[8]  = 'Eighty '
s_Tens[9]  = 'Ninety '

s_HowMuch[1]   = ''
s_HowMuch[2]   = 'Thousand '
s_HowMuch[3]   = 'Million '
s_HowMuch[4]   = 'Billion '
s_HowMuch[5]   = 'Trillion '
s_HowMuch[6]   = 'Quadrillion '
s_HowMuch[7]   = 'Quintillion '         // Correct me if I'm wrong here.
s_HowMuch[8]   = 'Hextillion '         //  however I can't afford this much
money.
s_HowMuch[9]   = 'Heptillion '       //    Can you?
s_HowMuch[10] = 'Octillion '        //     ?

s_ToProcess     = Right(Left(s_Amount,i_Len),3)
s_Remain          = Left(s_Amount,i_Len)

DO WHILE s_ToProcess <> ""

     i_Ctr ++

     s_Number   = String(Integer(s_ToProcess),'000')

     i_Hundreds = Integer(Mid(s_Number,1,1))
     i_Tens         = Integer(Mid(s_Number,2,1))
     i_Ones        = Integer(Mid(s_Number,3,1))

     IF i_Hundreds > 0 THEN
          s_Literal = s_Ones[i_Hundreds]  + 'Hundred '
     END IF

     IF i_Tens > 1 THEN
          i_Tens     = Integer(Mid(s_Number,2,1))
          s_Literal += s_Tens[i_Tens]
     ELSE
          i_Ones = Integer(Mid(s_Number,2,2))
     END IF    // i_Tens

     IF i_Ones > 0 THEN
          s_Literal += s_Ones[i_Ones]
     END IF

     s_Remain          =  Left(s_Remain,len(s_Remain) - 4 )
     s_Amount          =  s_Remain
     s_ToProcess    =  Right(s_Amount,3)

     s_Words[i_Ctr] = s_Literal + s_HowMuch[i_Ctr]

     s_Literal = ''

LOOP     // s_ToProcess <> ""

i_Words = UpperBound(s_Words)

FOR i_Ctr = i_Words TO 1 STEP -1
      s_RetVal += s_Words[i_Ctr]
NEXT

s_RetVal += 'and ' + Right(as_Amount,2) + '/100'

RETURN s_RetVal

//*******************************************************


Ming Fang wrote in message ...
>Hi, there,
>
>I remember that I came across some objects which can convert a number into
>words.
>For example, 85 is converted to English words "Eighty five", but I can't
>remember
>it now. Does anyone know of any such code?
>
>Please email me regarding any information. Thanks.
>
>Ming
>
>---== Posted via the PFCGuide Web Newsreader ==---
>http://www.pfcguide.com/_newsgroups/group_list.asp


1
Jun
4/13/2000 6:25:45 PM
Peace!

BTW, I forgot to mention the argument declaration:

Argument  Name   :  as_Amount
Argument  Type     :  String
Return Type           :  String

Usage:

s_YourMoney = '123,456,789.00'

s_WhatEver = of_NumToWords(as_YourMoney)

Returns a string of literal values (e.g.  "Eighty Five  and 00/100 "-- for
85.00 )

Thanks!

Jun Miano -- Jun@hcdc.fapenet.org



Jun Miano wrote in message ...
>Hi!
>
>Try this little snippet I made just for you.:-)))
>
>Any comments and suggestions are most welcome.
>
>//*************************************************************************
*
>********
>// Function Name: of_NumToWords
>// Purpose           : Convert number into words
>// Author              : Jun Miano  E-Mail :  Jun@HCDC.Fapenet.org
>// Revised Date : April 13,2000
>// Usage             : s_RetVal = of_NumToWords("123,456,789.00")
>//*************************************************************************
*
>********
>
>// Comments     : Self - Explanatory
>
>// Any revision  please let me know.
>
>
>//***********************
>Int   i_Len,     &
>       i_Ctr,     &
>       i_Number,  &
>       i_Hundreds,&
>       i_Tens,    &
>       i_Ones,    &
>       i_Words
>
>String s_Amount,   &
>       s_Number,   &
>       s_Literal,  &
>       s_Remain,   &
>       s_ToProcess,&
>       s_RetVal
>
>String s_Tens[9], s_Ones[19], s_HowMuch[10], s_Words[10]
>
>s_Literal = ''
>s_Words[1] = ' '
>
>s_Amount = as_Amount
>
>IF Integer(s_Amount) = 0 THEN RETURN 'Zero'
>
>i_Len = Len(s_Amount) - 3
>
>IF i_Len = 3 THEN RETURN Right(s_Amount,2) + '/100'
>
>s_Ones[1]  = 'One '
>s_Ones[2]  = 'Two '
>s_Ones[3]  = 'Three '
>s_Ones[4]  = 'Four '
>s_Ones[5]  = 'Five '
>s_Ones[6]  = 'Six '
>s_Ones[7]  = 'Seven '
>s_Ones[8]  = 'Eight '
>s_Ones[9]  = 'Nine '
>s_Ones[10] = 'Ten '
>s_Ones[11] = 'Eleven '
>s_Ones[12] = 'Twelve '
>s_Ones[13] = 'Thirteen '
>s_Ones[14] = 'Fourteen '
>s_Ones[15] = 'Fifteen '
>s_Ones[16] = 'Sixteen '
>s_Ones[17] = 'Seventeen '
>s_Ones[18] = 'Eighteen '
>s_Ones[19] = 'Nineteen '
>
>s_Tens[1]  = ' '
>s_Tens[2]  = 'Twenty '
>s_Tens[3]  = 'Thirty '
>s_Tens[4]  = 'Fourty '
>s_Tens[5]  = 'Fifty '
>s_Tens[6]  = 'Sixty '
>s_Tens[7]  = 'Seventy '
>s_Tens[8]  = 'Eighty '
>s_Tens[9]  = 'Ninety '
>
>s_HowMuch[1]   = ''
>s_HowMuch[2]   = 'Thousand '
>s_HowMuch[3]   = 'Million '
>s_HowMuch[4]   = 'Billion '
>s_HowMuch[5]   = 'Trillion '
>s_HowMuch[6]   = 'Quadrillion '
>s_HowMuch[7]   = 'Quintillion '         // Correct me if I'm wrong here.
>s_HowMuch[8]   = 'Hextillion '         //  however I can't afford this much
>money.
>s_HowMuch[9]   = 'Heptillion '       //    Can you?
>s_HowMuch[10] = 'Octillion '        //     ?
>
>s_ToProcess     = Right(Left(s_Amount,i_Len),3)
>s_Remain          = Left(s_Amount,i_Len)
>
>DO WHILE s_ToProcess <> ""
>
>     i_Ctr ++
>
>     s_Number   = String(Integer(s_ToProcess),'000')
>
>     i_Hundreds = Integer(Mid(s_Number,1,1))
>     i_Tens         = Integer(Mid(s_Number,2,1))
>     i_Ones        = Integer(Mid(s_Number,3,1))
>
>     IF i_Hundreds > 0 THEN
>          s_Literal = s_Ones[i_Hundreds]  + 'Hundred '
>     END IF
>
>     IF i_Tens > 1 THEN
>          i_Tens     = Integer(Mid(s_Number,2,1))
>          s_Literal += s_Tens[i_Tens]
>     ELSE
>          i_Ones = Integer(Mid(s_Number,2,2))
>     END IF    // i_Tens
>
>     IF i_Ones > 0 THEN
>          s_Literal += s_Ones[i_Ones]
>     END IF
>
>     s_Remain          =  Left(s_Remain,len(s_Remain) - 4 )
>     s_Amount          =  s_Remain
>     s_ToProcess    =  Right(s_Amount,3)
>
>     s_Words[i_Ctr] = s_Literal + s_HowMuch[i_Ctr]
>
>     s_Literal = ''
>
>LOOP     // s_ToProcess <> ""
>
>i_Words = UpperBound(s_Words)
>
>FOR i_Ctr = i_Words TO 1 STEP -1
>      s_RetVal += s_Words[i_Ctr]
>NEXT
>
>s_RetVal += 'and ' + Right(as_Amount,2) + '/100'
>
>RETURN s_RetVal
>
>//*******************************************************
>
>
>Ming Fang wrote in message ...
>>Hi, there,
>>
>>I remember that I came across some objects which can convert a number into
>>words.
>>For example, 85 is converted to English words "Eighty five", but I can't
>>remember
>>it now. Does anyone know of any such code?
>>
>>Please email me regarding any information. Thanks.
>>
>>Ming
>>
>>---== Posted via the PFCGuide Web Newsreader ==---
>>http://www.pfcguide.com/_newsgroups/group_list.asp
>
>


1
Jun
4/13/2000 6:58:44 PM
Reply:

Similar Artilces:

Code for converting numbers to words
Does the PFC libraries have a function to change a number into words like you would do on a check? It is really amazing how FAQ this is. If you don't have time to search www.dejanews.com , check out Code examples which come with PowerBuilder. Cashtrack application has this in it. -- pbm_thisusuallydoesnothelp:-)) Philip Salgannik "Chris Fauvel" <Chris.Fauvel@prof-programs.com> wrote in message news:AI14BeRDAHA.297@forums.sybase.com... > Does the PFC libraries have a function to change a number into words like > you would do on a check? >...

How to convert Powerbuilder code to Java code?
I want to convert my Non visual userobject code to Java code. Is there any way to convert powerbuilder code to Java code. We are currently migrating our application to java. We want to make use business object. Is there any way to make use of buisness object (user object ) in Java. How to convert code instead of rewrite. Thanks I don't know of any tools that will convert PB code to Java. I think you will have to rewrite it. Regards, Dave Fish [Team Sybase] On Wed, 10 Nov 1999 10:18:44 -0500, "Manju" <manjunathas@yahoo.com> wrote: > I want ...

convert number to word
Hi, Can any one help me ? How to convert number to word? ie., 123......means .........one hundereden twenty three. Regards pvs "Preeth" <preethavswamy@yahoo.com> �������/�������� � �������� ���������: news:WGCbtCRdCHA.278@forums.sybase.com... > Hi, > > Can any one help me ? How to convert number to word? > ie., 123......means .........one hundereden twenty three. > > Regards > pvs > > > I use computed field Preeth wrote: >Hi, > >Can any one help me ? How to convert number to word? >ie., 123.........

Converting numbers to words
Does anybody have code that converts a number w/ decimals into words, as one might do when writing a check? I'm lazy and don't want to re-invent the wheel. :-) See my reply in PFC group (And why crosspost?) -- pbm_thisusuallydoesnothelp:-)) Philip Salgannik "Chris Fauvel" <Chris.Fauvel@prof-programs.com> wrote in message news:WOzvofRDAHA.280@forums.sybase.com... > Does anybody have code that converts a number w/ decimals into words, as one > might do when writing a check? > > I'm lazy and don't want to re-invent the wheel...

Convert numbers to words
Is there a function or simple way to convert a number into words. This would be used for printing numbers as words onto a bank check. i.e. 1,230.02 converted to one thousand two hundred thirty and two cents I could use a case statement and convert each number to a word but this would be very long and cumbersome. I am using ASA 9.0.2 build 3661 Thanks Here's a set of functions I migrated from a PowerBuilder application. It requires two tables (that would probably work better as local temporary tables...) Invoke it with SELECT uf_verbalize_amount( <decimal val...

How to convert number into words?
Any functions are used to convert number into words? For example, 12 --> Twelve Dollars Thx, DS DS Attached is num_to_words function from the CashTrak example application HTH Alex Osin <DS> wrote in message news:0BDE59311E7C67EF000CC6CE85256D28.000CC6F885256D28@webforums... > Any functions are used to convert number into words? For example, 12 --> > Twelve Dollars > > Thx, > DS begin 666 num_to_words.srf M)%!"17AP;W)T2&5A9&5R)&YU;5]T;U]W;W)D<RYS<F8-"B100D5X<&]R=$-O M;6UE;G1S)$$@9G5N8W1I;VX@=&\@8V]...

Converting current code (Powerbuilder 6.5.1) to newest version of Powerbuilder?
Hi, can anyone tell me what you have to do in order to convert existing code (applications) (created under Powerbuilder 6.5.1) to the newest version of Powerbuilder (at least PB 8) and what it would take to use that code (applications) on the web, I do understand that the newer versions of PB have a web datawindow, is that all we would need to use to move our applications to the web? Thanks Look in this newsgroup aroung 01/08/02 for "Applications on the Web" (started by "John") for a good stream of information. JKerstens <John.Kerstens@gnb.ca> wrot...

Convert number to English Word
I would like to ask if there is any method to convert a number (intger or long) into spoken english words? For example, 123 --> one hundred and twenty-three. Many thanks ramram this it the exercise people do in undergraduate courses. take out any book and it should have the code ready or you can write one yourself with an hour's work. I have five ASP.NET books, and no such code example is provided. Ramram49, there is no existing method to do what you want. You will indeed have to create your own. As HelpWanted suggested, it would not be not hard. (And it will be an excelle...

Is there any function to convert number to word?
Is there any ready to use or library todownload to change number into word i.e. 100 => one hundred. Now, I create function to convert in other language than English but for English language I suppose it should exists anywhere, therefore I ask for your opinion. I see it is the general fx come with MS Access but I dont know whether there is this fx in PB. Thanks for yr help Patric Hi there, Here's an example, all credits go to Philip Salgannik $PBExportHeader$u_number_to_words_ps.sru forward global type u_number_to_words_ps from nonvisualobject end type end fo...

function for convert numbers to words
anyone have a function to convert numbers to words..... thanks..... PB doesn't provide words as a format option for numbers. However, Funcky is a library which you can add on to PB for not too much money. It has a function which does this. www.dlesko.com. Regards, John Olson Team Sybase Cornelio Royer wrote in message ... >anyone have a function to convert numbers to words..... > > >thanks..... > > On Mon, 3 Apr 2000 14:05:54 -0500, "Cornelio Royer" <cornelior@cwp.net.pa> wrote: >anyone have a function to conve...

function to convert numbers to word
anyone have a function to convert numbers to words. thanks.... ---== Posted via the PFCGuide Web Newsreader ==--- http://www.pfcguide.com/_newsgroups/group_list.asp ...

Converting Numbers to words #2
Hello ! We need a function which converts a number to words. This function should work in English and in German. Does anybody know a site with a code for such a function?? Thanks. Roman TUDER (pcd-m02@inca.at) This is a multi-part message in MIME format. --------------BD894773A4A1F0170A1DFB18 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Here is the NVO for english, but you can modify that according to your needs. I got this NVO from dean jones. Roman Tuder wrote: > Hello ! > > We need a function which converts a number...

Seperating Admin code in code-behind from general code
Hi guys, I just want to know if it would improve the functioning of my site to create two seperate dlls: One of the dll's would contain all the code for the general functioning of the site, and the other dll would contain all of the code for the administration elements of the site. Thanks GP...

How to find the number of lines of code in Powerbuilder
Hi All, I have a powerbuilder application with 18 PBL's . I would like to know the number of Lines Of Code used through out the application. Is it possible? Please let me know. Thanks Anand One of the things you'll have to decide is if you want just the number of lines in scripts, or if you want to include the lines generated by PB that you don't necessarily see (like control attributes, forward declarations, DataWindow definition lines, etc....). PBL Peeper (see below) will give you both, from the View / Show menu item while on the Lists / Objects and List...

Web resources about - Code converting numbers into words - sybase.powerbuilder.general

Facebook Begins Converting Users To HTTPS
Are you willing to sacrifice a little bit of speed for a lot more safety? Facebook is asking that very question with its announcement that it ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Vert - simply converting for iPhone, iPad, and iPod touch on the iTunes App Store
Get Vert - simply converting on the App Store. See screenshots and ratings, and read customer reviews.

Converting SIM Card to Micro SIM Card - Flickr - Photo Sharing!
Place new Micro SIM into the iPhone SIM card tray

Ayaan Hirsi Ali on Converting Muslims to Christianity - YouTube
Complete video at: http://fora.tv/2010/07/29/Nomad_From_Islam_to_America_with_Ayaan_Hirsi_Ali Ayaan Hirsi Ali explains her support of missionary ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Rothesay building new arena, converting existing rink to fieldhouse
The Town of Rothesay plans to build a new arena and convert the existing one into a fieldhouse.

Resources last updated: 1/22/2016 6:41:38 AM