[VB.NET] Fungsi Terbilang


Description
     berikut adalah fungsi terbilang yang biasa berguna dalam keuangan.  

How To

1. write this code below in module :

Private Function terbilang_amount(ByVal Amount) As String
        Dim bilangan() As String = {"", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas"}
        If Amount < 12 Then
            Return " " & bilangan(Amount)
        ElseIf Amount < 20 Then
            Return terbilang_amount(Amount - 10) & " belas"
        ElseIf Amount < 100 Then
            Return (terbilang_amount(CInt((Amount \ 10))) & " puluh") + terbilang_amount(Amount Mod 10)
        ElseIf Amount < 200 Then
            Return " seratus" & terbilang_amount(Amount - 100)
        ElseIf Amount < 1000 Then
            Return (terbilang_amount(CInt((Amount \ 100))) & " ratus") + terbilang_amount(Amount Mod 100)
        ElseIf Amount < 2000 Then
            Return " seribu" & terbilang_amount(Amount - 1000)
        ElseIf Amount < 1000000 Then
            Return (terbilang_amount(CInt((Amount \ 1000))) & " ribu") + terbilang_amount(Amount Mod 1000)
        ElseIf Amount < 1000000000 Then
            Return (terbilang_amount(CInt((Amount \ 1000000))) & " juta") + terbilang_amount(Amount Mod 1000000)
        ElseIf Amount < 1000000000000 Then
            Return (terbilang_amount(CInt((Amount \ 1000000000))) & " milyar") + terbilang_amount(Amount Mod 1000000000)
        ElseIf Amount < 1000000000000000 Then
            Return (terbilang_amount(CInt((Amount \ 1000000000000))) & " trilyun") + terbilang_amount(Amount Mod 1000000000000)
        Else
            Return ""
        End If
    End Function


to use, just call the function !! for example : terbilang_amount(12300) & " rupiah"

will be returned : "dua belas ribu tiga ratus rupiah"

Post a Comment

Harap gunakan bahasa yang baik dan sopan, terima kasih