Click here to Skip to main content
15,917,618 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Please suggest me the code to convert number into words like:
100:-hundred,1234=one thousand two hundred thirty four..........
Please give me the coding of this question in VS2005/2008 c# coding .
Posted
Updated 13-May-10 5:13am
v6

This has been asked and answered many times here. It's a homework assignment, and you were given the assignment to learn something. Part of that "learning" process is how to analyze a problem and subsequently develop a solution.
 
Share this answer
 
I have Googled it for you: Results[^]
 
Share this answer
 
Colin Mackay has an excellent example here[^] that you should really read through.
 
Share this answer
 
What have you done so far? It doesn't look a daunting task. Please try yourself and ask only specific questions here.
:)
 
Share this answer
 
1) Don't ask for code. We don't do your homework for you!
2) Don't use txtspk. You have a keyboard. Learn where the vowels are, and start using them.
3) Try this:
public static string GetNumberInWords(int a)
   {
   if (a==1)
      {
      return "One";
      }
   else if (a==2)
      {
      return "Two";
      }
   else if (a==3)
      {
      return "Three";
      }
   // else if... repeat till 999
   }

My thanks to Smithers-Jones for this excellent code fragment.

[edit]Removed spurious characters from code fragment[/edit]
 
Share this answer
 
v2
Comments
Smithers-Jones 11-May-10 8:38am    
You're welcome :-)
Here is the link to a page with some code that should help:-

http://www.daniweb.com/code/snippet216623.html#[^]
 
Share this answer
 
Try This, It works

numbervar RmVal:=0; 
numbervar Amt:=0; 
numbervar pAmt:=0; 
stringvar InWords :="Rupees ";

Amt := type your value ; // 25,12,000


if Amt > 10000000 then RmVal := truncate(Amt/10000000); 
if Amt = 10000000 then RmVal := 1;

   if RmVal = 1 then 
        InWords := InWords + " " + towords(RmVal,0) + " crore" 
   else 
        if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " crores";


    Amt := Amt - Rmval * 10000000;

    if Amt > 100000 then RmVal := truncate(Amt/100000); 
    if Amt = 100000 then RmVal := 1;

    if RmVal = 1 then 
        InWords := InWords + " " + towords(RmVal,0) + " lakhs"
    Else
        If RmVal > 1 then InWords := InWords + " " + ToWords(RmVal,0) + "Lakhs";

        Amt := Amt - Rmval * 100000;

        if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0);

        pAmt := (Amt - truncate(Amt)) * 100;

        if pAmt > 0 then 
            InWords := InWords + " and " + towords(pAmt,0) + " paisa only" 
        else 
            InWords := InWords + " only";

        UPPERCASE(InWords)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900