In many of the software it’s required to transform the quantity or quantity in phrases. Following code will enable you to to transform a given quantity into phrases. For instance, if “1234″ is given as enter, output can be “One Thousand Two Hundred Thirty 4”.
This code will probably be convert any quantity between 1 to 9999 in phrases.
[csharp]
string[] Ones = { “One”, “Two”, “Three”, “4”, “5”, “Six”, “Seven”, “Eight”, “9”, “Ten”, “Eleven”, “Twelve”, “13”, “Fourteen”, “Fifteen”, “Sixteen”, “Seventeen”, “Eighteen”, “Ninteen” };
string[] Tens = { “Ten”, “Twenty”, “Thirty”, “Fourty”, “Fift”, “Sixty”, “Seventy”, “Eighty”, “Ninty” };
int no = int.Parse(txtNumber.Textual content);
string strWords = “”;
if (no > 999 && no < 10000) { int i = no / 1000; strWords = strWords + Ones[i – 1] + ” Thousand “; no = no % 1000; }
if (no > 99 && no < 1000) { int i = no / 100; strWords = strWords + Ones[i – 1] + ” Hundred “; no = no % 100; }
if (no > 19 && no < 100) { int i = no / 10; strWords = strWords + Tens[i – 1] + ” “; no = no % 10; }
if (no > 0 && no < 20) { strWords = strWords + Ones[no – 1]; }
label2.Textual content = strWords;
[/csharp]
Supply techzoo.org