Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function Terbilang(q As Currency)
- Dim satuan(10) As String
- satuan(0) = "Nol"
- satuan(1) = "Satu"
- satuan(2) = "Dua"
- satuan(3) = "Tiga"
- satuan(4) = "Empat"
- satuan(5) = "Lima"
- satuan(6) = "Enam"
- satuan(7) = "Tujuh"
- satuan(8) = "Delapan"
- satuan(9) = "Sembilan"
- Dim ribuan(5) As String
- ribuan(0) = ""
- ribuan(1) = "Ribu"
- ribuan(2) = "Juta"
- ribuan(3) = "Miliar"
- ribuan(4) = "Triliun"
- Dim x As Currency
- x = Int(q)
- Dim tera As Currency
- tera = Int(q / 1000000000000#)
- Dim giga As Currency
- giga = Int((q - tera * 1000000000000#) / 1000000000)
- Dim mega As Currency
- mega = Int((q - tera * 1000000000000# - giga * 1000000000) / 1000000)
- Dim kilo As Currency
- kilo = Int((q - tera * 1000000000000# - giga * 1000000000 - mega * 1000000) / 1000)
- Dim unit As Currency
- unit = Int((q - tera * 1000000000000# - giga * 1000000000 - mega * 1000000 - kilo * 1000) / 1)
- Dim sen As Currency
- sen = Int((q - Int(q)) * 100)
- Dim arr(5) As Integer
- arr(0) = Int(unit)
- arr(1) = Int(kilo)
- arr(2) = Int(mega)
- arr(3) = Int(giga)
- arr(4) = Int(tera)
- Dim result(5) As String
- result(0) = ""
- result(1) = ""
- result(2) = ""
- result(3) = ""
- result(4) = ""
- Dim k As Integer
- Dim v As Integer
- Dim ratus As Integer
- Dim puluh As Integer
- Dim satu As Integer
- Dim title As String
- Dim perpuluh As Integer
- Dim perribu As Integer
- For k = 0 To 4
- v = arr(k)
- If v = 0 Then
- If k + x = 0 Then
- result(k) = "Nol "
- End If
- ElseIf k * v = 1 Then
- result(k) = "Seribu "
- ElseIf v > 0 Then
- ratus = Int(v / 100)
- puluh = Int((v - 100 * ratus) / 10)
- satu = Int((v - 100 * ratus - 10 * puluh) / 1)
- If ratus = 1 Then
- result(k) = "Seratus "
- ElseIf ratus > 0 Then
- result(k) = satuan(ratus) & " Ratus "
- End If
- If (puluh = 1) And (satu = 0) Then
- result(k) = result(k) & "Sepuluh "
- ElseIf puluh * satu = 1 Then
- result(k) = result(k) & "Sebelas "
- ElseIf puluh = 1 Then
- result(k) = result(k) & satuan(satu) & " Belas "
- Else
- If puluh > 1 Then
- result(k) = result(k) & satuan(puluh) & " Puluh "
- End If
- If satu > 0 Then
- result(k) = result(k) & satuan(satu) & " "
- End If
- End If
- If k > 0 Then
- result(k) = result(k) & ribuan(k) & " "
- End If
- End If
- Next k
- title = result(4) & result(3) & result(2) & result(1) & result(0)
- If sen > 0 Then
- perpuluh = Int(sen / 10)
- perribu = Int((sen - 10 * perpuluh) / 1)
- title = title & "Koma " & satuan(perpuluh) & " " & satuan(perribu)
- End If
- Terbilang = title & "Rupiah"
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement