Tutorial CSharp : Membuat Fungsi Terbilang C#

Tutorial CSharp : Cara Membuat Fungsi (Functions) Terbilang di CSharp (C#), Bagaimana cara membuat Fungsi Terbilang di C# lihat selengkapnya di Sector Code !

Cara Membuat Functions Terbilang di CSharp (C#)

Gimanasih cara membuat Fungsi terbilang menggunakan bahasa C# dibaca CSharp ?

Membuat aplikasi Iinventory sangat penting menggunakan Fungsi Terbilang ini, seperti Tutorial - Tutorial Visual Basic.Net yang sudah kami bahas sebelumnya tentang Tutorial Vb.Net : Nomor Faktur Otomatis Aplikasi Inventory,
Tutorial CSharp : Membuat Fungsi Terbilang C#

Langsung saja untuk membuat Fungsi Terbilang di C#, buatlah sebuah Form dengan nama "FrmUtama.Cs" dan Copy seluruh Code dibawah ini,
        string[] satuan = new string[10] { "nol", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan" };
        string[] belasan = new string[10] { "sepuluh", "sebelas", "dua belas", "tiga belas", "empat belas", "lima belas", "enam belas", "tujuh belas", "delapan belas", "sembilan belas" };
        string[] puluhan = new string[10] { "", "", "dua puluh", "tiga puluh", "empat puluh", "lima puluh", "enam puluh", "tujuh puluh", "delapan puluh", "sembilan puluh" };
        string[] ribuan = new string[5] { "", "ribu", "juta", "milyar", "triliyun" };

        string Terbilang(Decimal d)
        {
            string strHasil = "";
            Decimal frac = d - Decimal.Truncate(d);

            if (Decimal.Compare(frac, 0.0m) != 0)
                strHasil = Terbilang(Decimal.Round(frac * 100)) + " sen";
            else
                strHasil = "rupiah";
            int xDigit = 0;
            int xPosisi = 0;

            string strTemp = Decimal.Truncate(d).ToString();
            for (int i = strTemp.Length; i > 0; i--)
            {
                string tmpx = "";
                xDigit = Convert.ToInt32(strTemp.Substring(i - 1, 1));
                xPosisi = (strTemp.Length - i) + 1;
                switch (xPosisi % 3)
                {
                    case 1:
                        bool allNull = false;
                        if (i == 1)
                            tmpx = satuan[xDigit] + " ";
                        else if (strTemp.Substring(i - 2, 1) == "1")
                            tmpx = belasan[xDigit] + " ";
                        else if (xDigit > 0)
                            tmpx = satuan[xDigit] + " ";
                        else
                        {
                            allNull = true;
                            if (i > 1)
                                if (strTemp.Substring(i - 2, 1) != "0")
                                    allNull = false;
                            if (i > 2)
                                if (strTemp.Substring(i - 3, 1) != "0")
                                    allNull = false;
                            tmpx = "";
                        }

                        if ((!allNull) && (xPosisi > 1))
                            if ((strTemp.Length == 4) && (strTemp.Substring(0, 1) == "1"))
                                tmpx = "se" + ribuan[(int)Decimal.Round(xPosisi / 3m)] + " ";
                            else
                                tmpx = tmpx + ribuan[(int)Decimal.Round(xPosisi / 3)] + " ";
                        strHasil = tmpx + strHasil;
                        break;
                    case 2:
                        if (xDigit > 0)
                            strHasil = puluhan[xDigit] + " " + strHasil;
                        break;
                    case 0:
                        if (xDigit > 0)
                            if (xDigit == 1)
                                strHasil = "seratus " + strHasil;
                            else
                                strHasil = satuan[xDigit] + " ratus " + strHasil;
                        break;
                }
            }
            strHasil = strHasil.Trim().ToLower();
            if (strHasil.Length > 0)
            {
                strHasil = strHasil.Substring(0, 1).ToUpper() +
                  strHasil.Substring(1, strHasil.Length - 1);
            }
            return strHasil;
        }
Salin semua Code diatas, sebagaimana kita lihat Fungsi Terbilang menggunakan C#. Selanjutnya tinggal panggil saja pada event-event yang anda inginkan, sebagai contoh saya memanggil Fungsi terbilang tersebut pada label pada Event Button Klik.
        private void metroButton3_Click(object sender, EventArgs e)
        {
            metroLabel15.Text = this.Terbilang(tTotal).TrimStart();
        }
Jika semua sudah selesai, silahkan Run program anda, jangan lupa share jika bermanfaat, jika ada yang kurang jelas silahkan bertanya pada kolom komentar dibawah ini, Terima Kasih ;)

Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,89,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,6,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: Tutorial CSharp : Membuat Fungsi Terbilang C#
Tutorial CSharp : Membuat Fungsi Terbilang C#
Tutorial CSharp : Cara Membuat Fungsi (Functions) Terbilang di CSharp (C#), Bagaimana cara membuat Fungsi Terbilang di C# lihat selengkapnya di Sector Code !
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3sHLx7Bm7gtTGL7h1O59z22cQRYbnKiMMSlWDI6Mx-KLSS8g-DwIpjLfLxYQk1TsQ66YBAWbsww_vicPCKFsvK4XyHNYHs5DSsUrjAvlOOuh9WFc79JkLiFDNd5GMyFKg51zy-Usbl28/s320/membuat-fungsi-terbilang-csharp.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3sHLx7Bm7gtTGL7h1O59z22cQRYbnKiMMSlWDI6Mx-KLSS8g-DwIpjLfLxYQk1TsQ66YBAWbsww_vicPCKFsvK4XyHNYHs5DSsUrjAvlOOuh9WFc79JkLiFDNd5GMyFKg51zy-Usbl28/s72-c/membuat-fungsi-terbilang-csharp.png
KODE AJAIB
https://scqq.blogspot.com/2015/08/tutorial-csharp-membuat-fungsi-terbilang.html
https://scqq.blogspot.com/
https://scqq.blogspot.com/
https://scqq.blogspot.com/2015/08/tutorial-csharp-membuat-fungsi-terbilang.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy