Posted by: Red Souldier | May 26, 2009

Function Terbilang (Indonesia Currency) vb.net

This function is used to convert from numeric to text in indonesia language. This function was coded for vb.net

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: