Amount is display in Text format
HI any body please help i need Total amount display in text format like suppose the total amount was 2,0000 twenty thoused only or 2000 two thousend only ,two lackh only like that i need this programm in asp.net using c#
BalaPosted Apr 30, 2013, 2:59 AM
public class MoneyConverterinWords
{
static string SINGLES = "one,two,three,four,five,"
+"six,seven,eight,nine";
static string DECADES = "ten,eleven,twelve,thirteen,fourteen,"
+"fifteen,sixteen,seventeen,eighteen,nineteen";
static string DECTYS = "twenty,thirty,forty,fifty,"
+"sixty,seventy,eighty,ninety";
static string TIONS = ",thousand,million,billion";
public static string Num2Words(int iNum)
{
int i = iNum;
bool b = false;
string s="";
if (i < 0) { b = true; i = i * -1; }
if (i == 0)
{
s = "zero";
}
else if (i <= 2147483647)
{
string[] a = TIONS.Split(',');
for (int j = 0; j <= 3; j++)
{
int iii = i % 1000;
i = i / 1000;
if (iii > 0) s = nnn2words(iii) + " " + a[j] + " " + s;
}
}
else
{
s = "out of range value";
}
if (b) s = "negative " + s;
return s.Trim();
}
private static string nnn2words(int iNum)
{
string[] a = SINGLES.Split(',');
string s="";
int i = iNum % 10;
if (i > 0) s = a[i - 1];
int ii = Convert.ToInt32(iNum % 100) / 10;
if (ii == 1)
{
s = DECADES.Split(',')[i];
}
else if (((ii > 1) & (ii < 10)))
{
s = DECTYS.Split(',')[ii - 2] + " " + s;
}
i = (iNum / 100) % 10;
if (i > 0) s = a[i - 1] + " hundred " + s;
return s;
}
}
Ravi ShekharPosted Apr 30, 2013, 2:50 AM
Ravi ShekharPosted Apr 30, 2013, 2:49 AM
I am sharing a dll to convert NumtoWord.
Browse attached dll into your application . and call through
using NumToWord;
Now,
in str u 'll get " Rupees Two Hundred Thirty Five Only"
Regards,
Ravi