To convert numbers into words

Posted by Sathiya_Narayanan under ASP.NET AJAX on 4/16/2012 | Points: 10 | Views : 3175 | Status : [Member] | Replies : 11
Hi,
I have one textbox and one label
in that textbox when i entered text as 1 in label it must show as ONE
and also in textbox 15 01 1947 in label it should show FIFTEEN ONE NINTEENFOURTYSEVEN
how to do this task..






Thanks&regards,

SATHIYANARAYANAN


Responses

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Good queston Man

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Super Link

http://social.msdn.microsoft.com/Forums/nb-NO/csharpgeneral/thread/0b1dec9c-61e9-4544-8134-bda1264a21a4

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
public static string NumberToWords(int number)

{
if (number == 0)
return "zero";

if (number < 0)
return "minus " + NumberToWords(Math.Abs(number));

string words = "";

if ((number / 1000000) > 0)
{
words += NumberToWords(number / 1000000) + " million ";
number %= 1000000;
}

if ((number / 1000) > 0)
{
words += NumberToWords(number / 1000) + " thousand ";
number %= 1000;
}

if ((number / 100) > 0)
{
words += NumberToWords(number / 100) + " hundred ";
number %= 100;
}

if (number > 0)
{
if (words != "")
words += "and ";

var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };

if (number < 20)
words += unitsMap[number];
else
{
words += tensMap[number / 10];
if ((number % 10) > 0)
words += "-" + unitsMap[number % 10];
}
}

return words;
}


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
i thought That this link might be useful
http://midnightprogrammer.net/post/Convert-Numbers-to-Words-in-C.aspx

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
I these will be useful ..
Mark as Answer...

Otherwise Say ur Feedback

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sathiya_Narayanan on: 4/16/2012 [Member] Starter | Points: 25

Up
0
Down
Is this can be do by AJAX or Jscript is possible tell me how
bcoz it should happen before button click
as first we enter 1 & then we enter space then 10, it should display simultaneously when we press space

SATHIYANARAYANAN

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Sathiya_Narayanan

have u tried that Code


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sathiya_Narayanan on: 4/16/2012 [Member] Starter | Points: 25

Up
0
Down
nope

SATHIYANARAYANAN

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Sathiya_Narayanan

Just refer This Link ...

Try this Code You may Get different idea


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sathiya_Narayanan on: 4/16/2012 [Member] Starter | Points: 25

Up
0
Down
Ok sure..

SATHIYANARAYANAN

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Sathiya_Narayanan

Try it And Say


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response