Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# conversion
My form have 2 textboxes. For one text box i'm entering a number & when it's done i need to get the digit value in string format in other text box. Is this possible?
 

Ex: TextBox1 --> 100
TextBox2 --> One Hundred
Posted 24-Sep-12 21:32pm
Edited 24-Sep-12 23:37pm
v2
Comments
shambhoo kumar at 25-Sep-12 4:49am
   
yes this is possible...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
see the answers to this similar question:
how to convert numbers into texual format using c#[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Google is your friend.
See, for instance, converting numbers in to words C#[^] at stackoverflow.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
 
Have you tried in Google/CP?
 
Here is the CP link for you.
How to convert a numeric value or currency to English words using C#[^]
 
and here
 
Google[^]
 
Try in Google/CP before posting a Question
 
Thanks
--RA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

hiii,
 
Define Object as
 
textBox1.text=100
 

AmountInWords obj=new AmountInWords();
textbox2.Text=obj.ConvertAmount(Convert.ToDouble(textBox1.Text))
And Output is= One Hundred
 
where class file is
 
AmountInWords.cs
 
class AmountInWords
   {
       private static String[] units = { "Zero", "One", "Two", "Three",
           "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven",
           "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen",
           "Seventeen", "Eighteen", "Nineteen" };
       private static String[] tens = { "", "", "Twenty", "Thirty", "Forty",
           "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
 

       public String ConvertAmount(double amount)
       {
           try
           {
               int amount_int = (int)amount;
               int amount_dec = (int)Math.Round((amount - (double)(amount_int)) * 100);
               return convert(amount_int) + "  point "
                       + convert(amount_dec);
           }
           catch (Exception e)
           {
               // TODO: handle exception
           }
           return "";
       }
 
       public String convert(int i)
       {
           //
           if (i < 20)
               return units[i];
           if (i < 100)
               return tens[i / 10] + ((i % 10 > 0) ? " " + convert(i % 10) : "");
           if (i < 1000)
               return units[i / 100] + " Hundred"
                       + ((i % 100 > 0) ? " and " + convert(i % 100) : "");
           if (i < 100000)
               return convert(i / 1000) + " Thousand "
                       + ((i % 1000 > 0) ? " " + convert(i % 1000) : "");
           if (i < 10000000)
               return convert(i / 100000) + " Lakh "
                       + ((i % 100000 > 0) ? " " + convert(i % 100000) : "");
           return convert(i / 10000000) + " Crore "
                   + ((i % 10000000 > 0) ? " " + convert(i % 10000000) : "");
       }
 
   }
  Permalink  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 310
1 CPallini 310
2 George Jonsson 269
3 Gihan Liyanage 255
4 OriginalGriff 245
0 OriginalGriff 4,903
1 CPallini 3,960
2 Sergey Alexandrovich Kryukov 3,474
3 George Jonsson 2,786
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web01 | 2.8.140905.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100