convert amount to rupees and paise in words format in c#

convert number to words in indian rupees
convert number to words in c# windows application
convert number to words in indian rupees in vb net
convert number to arabic words c#
indian number converter
convert number to words with decimal
how to display number in words in ssrs report
how to convert numeric value to string in c#

I have windows application in which i need to convert amount entered in text-box into the words in ruppes and paise format. for e.g My amount is 2356.54 then it should display two thousand three hundred fifty six ruppes and fifty four paise only however, i have code that convert amt to words but i am not able to show paise.i am including my code for reference purpose.

private void btntowords_Click(object sender, EventArgs e)
        {
           MessageBox.Show( words(Convert.ToInt32(textBox1.Text)));
        }

        public string words(int numbers)
        {
            int number = numbers;

            if (number == 0) return "Zero";
            if (number == -2147483648) return "Minus Two Hundred and Fourteen Crore Seventy Four Lakh Eighty Three Thousand Six Hundred and Forty Eight";
            int[] num = new int[4];
            int first = 0;
            int u, h, t;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (number < 0)
            {
                sb.Append("Minus ");
                number = -number;
            }
            string[] words0 = {"" ,"One ", "Two ", "Three ", "Four ",
"Five " ,"Six ", "Seven ", "Eight ", "Nine "};
            string[] words1 = {"Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ",
"Fifteen ","Sixteen ","Seventeen ","Eighteen ", "Nineteen "};
            string[] words2 = {"Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ",
"Seventy ","Eighty ", "Ninety "};
            string[] words3 = { "Thousand ", "Lakh ", "Crore " };
            num[0] = number % 1000; // units
            num[1] = number / 1000;
            num[2] = number / 100000;
            num[1] = num[1] - 100 * num[2]; // thousands
            num[3] = number / 10000000; // crores
            num[2] = num[2] - 100 * num[3]; // lakhs
            for (int i = 3; i > 0; i--)
            {
                if (num[i] != 0)
                {
                    first = i;
                    break;
                }
            }
            for (int i = first; i >= 0; i--)
            {
                if (num[i] == 0) continue;
                u = num[i] % 10; // ones
                t = num[i] / 10;
                h = num[i] / 100; // hundreds
                t = t - 10 * h; // tens
                if (h > 0) sb.Append(words0[h] + "Hundred ");
                if (u > 0 || t > 0)
                {
                    if (h > 0 || i == 0) sb.Append("and ");
                    if (t == 0)
                        sb.Append(words0[u]);
                    else if (t == 1)
                        sb.Append(words1[u]);
                    else
                        sb.Append(words2[t - 2] + words0[u]);
                }
                if (i != 0) sb.Append(words3[i - 1]);
            }
            return sb.ToString().TrimEnd();
        }

It should not show pasie if it has amount like this 2356.00 so i have tried by many ways to get paise but not succeed. i have tried ggogle but not getting exactly what i want.

You need to separate the decimal number and get two separate values one before decimal place and one after it. For example in 56.2 you get 56 separately and 2 separately and call you words() function for both of them. You'll get two strings one "Fifty six" and second "two". You can join these strings to say "Fifty six rupee 2 paisas".

How to convert decimal amount like 123.12 number to word rupees , Convert Amount in Words and Separate Amount with comma in Bangladeshi Currency Format using C#.NET[^] Calling two functions can convert decimal amount like 123.12 number to word rupees and paise. this is the  This module converts the amount into words.Here if you enter some amount say 123.45 than you will get "One Hundereds Twenty Three Rupees and Forty Five Paise". This will give you result for maximun of (9,2) number

You need small change in your method. Please find below method

public string words(double? numbers, Boolean paisaconversion = false)
    {
        var pointindex = numbers.ToString().IndexOf(".");
        var paisaamt = 0;
        if (pointindex > 0)
         paisaamt = Convert.ToInt32( numbers.ToString().Substring(pointindex + 1, 2));

        int number = Convert.ToInt32( numbers);

        if (number == 0) return "Zero";
        if (number == -2147483648) return "Minus Two Hundred and Fourteen Crore Seventy Four Lakh Eighty Three Thousand Six Hundred and Forty Eight";
        int[] num = new int[4];
        int first = 0;
        int u, h, t;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        if (number < 0)
        {
            sb.Append("Minus ");
            number = -number;
        }
        string[] words0 = {"" ,"One ", "Two ", "Three ", "Four ","Five " ,"Six ", "Seven ", "Eight ", "Nine "};
        string[] words1 = {"Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ","Fifteen ","Sixteen ","Seventeen ","Eighteen ", "Nineteen "};
        string[] words2 = {"Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ","Seventy ","Eighty ", "Ninety "};
        string[] words3 = { "Thousand ", "Lakh ", "Crore " };
        num[0] = number % 1000; // units
        num[1] = number / 1000;
        num[2] = number / 100000;
        num[1] = num[1] - 100 * num[2]; // thousands
        num[3] = number / 10000000; // crores
        num[2] = num[2] - 100 * num[3]; // lakhs
        for (int i = 3; i > 0; i--)
        {
            if (num[i] != 0)
            {
                first = i;
                break;
            }
        }
        for (int i = first; i >= 0; i--)
        {
            if (num[i] == 0) continue;
            u = num[i] % 10; // ones
            t = num[i] / 10;
            h = num[i] / 100; // hundreds
            t = t - 10 * h; // tens
            if (h > 0) sb.Append(words0[h] + "Hundred ");
            if (u > 0 || t > 0)
            {
                if (h > 0 || i == 0) sb.Append("and ");
                if (t == 0)
                    sb.Append(words0[u]);
                else if (t == 1)
                    sb.Append(words1[u]);
                else
                    sb.Append(words2[t - 2] + words0[u]);
            }
            if (i != 0) sb.Append(words3[i - 1]);
        }

        if (paisaamt == 0 && paisaconversion == false)
        {
            sb.Append("ruppes only");
        }
        else if (paisaamt > 0)
        {
            var paisatext = words(paisaamt, true);
            sb.AppendFormat("rupees {0} paise only", paisatext);
        }
        return sb.ToString().TrimEnd();
    }

Convert Numeric Value Into Words (Currency) In C#, 568.25 = Five Hundred Sixty Eight and two five paisa only. -25 = Minus twenty five only. Explanation. Let's begin converting numeric value into words. Here, I am giving Indian currency format like if the number contains a  Introduction. In some situations, we will get a requirement like converting a number into words. Example. 568 = Five Hundred Sixty Eight only. Here, I will explain how to convert this numeric value to words (In Indian Currency format), using C#, not only whole numbers but also with decimal and negative values.

Give input as number upto 999999999 the output will be in words.

class A
{
    string[] words0 = { "Zero ", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen ", "Twenty " };
    string[] words2 = { "Zero ", "Ten ", "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety ", "Hundred " };
    string[] words3 = { "Hundred ", "Thousand ", "Lakh ", "Crore " };
    int[] numbers = new int[] { 0, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
    string numstr;
    string words = "";
    int tempNum;
    int temp = 0;

    public void ConvertToRupee(int number)
    {
        numstr = number.ToString();
        words = "";
        tempNum = number;
        temp = 0;
        while (numstr != "0" && numstr.Length != 0)
        {
            switch (numstr.Length)
            {
                case 1:
                    words += words0[tempNum];
                    numstr = "";
                    break;
                case 2:
                    if (tempNum <= 20)
                    {
                        words += words0[tempNum];
                        numstr = "";
                    }
                    else
                    {
                        temp = tempNum / numbers[2];
                        words += words2[temp];
                        tempNum = tempNum % numbers[2];
                        numstr = tempNum.ToString();
                    }
                    break;
                case 3:
                    Method1(3, "Hundred ");
                    break;
                case 4:
                    Method1(4, "Thousand ");
                    break;
                case 5:
                    Method2(4, "Thousand ");
                    break;
                case 6:
                    Method1(6, "Lakh ");
                    break;
                case 7:
                    Method2(6, "Lakh ");
                    break;
                case 8:
                    Method1(8, "Crore ");
                    break;
                case 9:
                    Method2(8, "Crore ");
                    break;
                default:
                    break;
            }
        }
        words += "Rupees Only ";
        Console.WriteLine(number.ToString() + " : " + words);
    }

    private void Method1(int n, string wo)
    {
        temp = tempNum / numbers[n];
        words += words0[temp] + wo;
        tempNum = tempNum % numbers[n];
        numstr = tempNum.ToString();
    }

    private void Method2(int n, string wo)
    {
        temp = tempNum / numbers[n];
        if (temp == 10)
            words += words0[temp] + wo;
        else if (temp <= 20)
            words += words0[temp] + wo;
        else
        {
            int twoDig = temp / numbers[2];
            int digit = temp % numbers[2];
            words += words2[twoDig] + words0[digit] + wo;
        }
        tempNum = tempNum % numbers[n];
        numstr = tempNum.ToString();
    }
}

Convert amount into words (Rupees), amount into words.Here if you enter some amount say 123.45 than you will get "One Hundereds Twenty Three Rupees and Forty Five Paise". How to convert number to words in indian rupees in rupee and paise like 1110.56 C# in word like, one thousand one hundred ten rupees and fifty six paise.

Convert Rupees (Numbers) to Words (String) using C#.NET, The resource is about converting amount into words and taking care of rupees as well as paise. In some application when we work with Amount  Hi Everyone. I have task to convert rupees in words upto 10 lakhs using c#. During calculation i want to show the full amount as well as in words.Please do help meThanx In advance..:):)

Convert Money from Numbers to words including paise, Here I will explain how to convert currency to words in asp.net using c# or convert numbers to words in asp.net using c# with example or convert currency  Conver number into word how to convert number into words in C# It seems this is a perennial first year class assignment. And then all the students are so proud of their creations that they post them here. Similarly, please consider that teachers know about this site and will know if you simply copied (plagiarized) any of these implementations.

Asp.net Convert Rupees (Numbers) to Words (String) using C#.NET , Hi Everyone. I have task to convert rupees in words upto 10 lakhs using c#. During calculation i want to show the full amount as well as in  Using PHP how to convert number to Indian currency word format with paise (decimal value) Input 190908100.25. Output we need. nineteen crores nine lakh eight thousand one hundred Rupees .two five Paise I expect this conversion method in core php.

Comments
  • I think its better to change if (h > 0 || i == 0) sb.Append("and "); to if (h != 0 && i == 0) sb.Append("and "); . Because when conversting 99 to words ,class returning " and ninety-nine".
  • What a mess! This is just a big, useless code dump, and the code isn't even properly formatted so it is readable!