Bagaimanakah menjadikan angka menjadi kata-kata agar tidak salah ketik? misalnya dalam pembuatan kuitansi.
ex. :
Rp. 12.000,-
terbilang: Dua belas ribu rupiah
Gunakan skrip di bawah inipada macro VBA.
================================
Function sbt(c As Long)
If (c = 2 ) Then sbt = “puluh”
If (c = 3 ) Then sbt = “ratus”
If (c = 4 ) Then sbt = “ribu”
If (c = 5 ) Then sbt = “puluh”
If (c = 6 ) Then sbt = “ratus”
If (c = 7 ) Then sbt = “juta”
If (c = 8 ) Then sbt = “puluh”
If (c = 9 ) Then sbt = “ratus”
If (c = 10 ) Then sbt = “milyar”
If (c = 11 ) Then sbt = “puluh”
End Function
Private Function nm(cx As String)
If (cx = “1″ ) Then nm = “satu”
If (cx = “2″ ) Then nm = “dua”
If (cx = “3″ ) Then nm = “tiga”
If (cx = “4″ ) Then nm = “empat”
If (cx = “5″ ) Then nm = “lima”
If (cx = “6″ ) Then nm = “enam”
If (cx = “7″ ) Then nm = “tujuh”
If (cx = “8″ ) Then nm = “delapan”
If (cx = “9″ ) Then nm = “sembilan”
If (cx = “0″ ) Then nm = “nol”
End Function
Function bilang(angka As String ) As String
Dim ang As Long
Dim bulat As String
Dim bul As Long
Dim x As Long
Dim pos As Long
Dim z As String
Dim w As String
Dim y As Long
Dim k1 As String
Dim k2 As String
Dim yy As Long
Dim ext As String
Dim stp As Long
Dim v As String
ang = Len( angka )
bulat = angka
bul = Len( bulat )
x = bul
stp = 0
Do While (x > 0 )
pos = bul – x + 1
z = Mid(bulat, pos, 1 )
w = Mid(bulat, pos )
y = Len(w)
If (z <> “0″ ) Then
‘jika angkanya bukan nol
If ( z = “1″ And ( y = 2 Or y = 5 Or y = 8 Or y = 11 ) ) Then
‘jika angka 1 dan merupakan puluhan, puluh ribu, puluh juta, puluh milyar
v = Mid(bulat, pos + 1, 1 )
If ( v = “1″ ) Then
‘ jika angka belakangnya = 1
k1 = “sebelas ”
yy = y – 1
k2 = sbt( y – 1 )
ElseIf (v = “0″ ) Then
‘jika angka belakangya = 0
k1 = “se”
k1 = k1 & sbt( y )
k1 = k1 & ” ” & sbt( y – 1 )
k2 = “”
Else
‘jika angka di belakngnya bukan 1 ataupun 0
k1 = nm( v ) & ” belas”
yy = y – 1
k2 = sbt( y – 1 )
End If
stp = 0
ext = k1 & ” ” & k2
x = x – 1
ElseIf ( z = “1″ And pos = 1 And ( y = 3 Or y = 4 Or y = 6 Or y = 9 ) ) Then
‘ jika angka 1 di posisi paling depan dan merupakan ratusan, ribuan, ratusan ribu, ratusan juta
k1 = “se”
k2 = sbt( y )
ext = k1 & k2
ElseIf ( z = “1″ And ( y = 3 Or y = 6 Or y = 9 ) And Mid(bulat, pos + 1, 1 ) = “0″ And Mid(bulat, pos + 2, 1) = “0″ ) Then
k1 = “se”
k2 = sbt( y ) & ” ” & sbt( y – 2 )
ext = k1 & k2
x = x – 2
ElseIf ( z = “1″ And ( y = 3 Or y = 6 Or y = 9 ) ) Then
‘ jika angka 1 di posisi ratusan, ratusan ribu, ratusan juta
k1 = “se”
k2 = sbt( y )
ext = k1 & k2
ElseIf ( z <> “1″ And ( y = 3 Or y = 6 Or y = 9 ) And Mid( bulat, pos + 1, 1 ) = “0″ And Mid(bulat, pos + 2, 1 ) = “0″ ) Then
‘jika buka angka 1 dan merupakan ratusan bulat, ratusan ribu bulat, ratusan juta bulat
k1 = nm(z)
k2 = sbt(y) & ” ” & sbt(y – 2)
ext = k1 & ” ” & k2
x = x – 2
ElseIf ( z <> “1″ And (y = 5 Or y = 8 Or y = 11 ) And Mid(bulat, pos + 1, 1 ) = “0″ ) Then
k1 = nm( z )
k2 = sbt(y) & ” ” & sbt( y – 1 )
ext = k1 & ” ” & k2
x = x – 1
Else
k1 = nm( z )
k2 = sbt( y )
ext = k1 & ” ” & k2
End If
ElseIf ( z = “0″ And ( y = 4 Or y = 7 Or y = 10 ) And stp = 0 ) Then
‘jika angka 0 dan merupakan ribuan, jutaan, milyaran
If (Mid( bulat, pos – 1, 1 ) <> 0 ) Then
ext = sbt( y )
End If
stp = 1
Else
ext = “”
End If
If (ext <> “” And bilang <> “” ) Then
bilang = bilang & ” ” & ext
ElseIf (ext <> “” And bilang = “” ) Then
bilang = ext
End If
x = x – 1
Loop
bilang = UCase(Mid(bilang, 1, 1 ) ) & Mid(bilang, 2 ) & ” rupiah”
End Function
Sub baru()
End Sub
=============================
ex. :
Rp. 12.000,-
terbilang: Dua belas ribu rupiah
Gunakan skrip di bawah inipada macro VBA.
================================
Function sbt(c As Long)
If (c = 2 ) Then sbt = “puluh”
If (c = 3 ) Then sbt = “ratus”
If (c = 4 ) Then sbt = “ribu”
If (c = 5 ) Then sbt = “puluh”
If (c = 6 ) Then sbt = “ratus”
If (c = 7 ) Then sbt = “juta”
If (c = 8 ) Then sbt = “puluh”
If (c = 9 ) Then sbt = “ratus”
If (c = 10 ) Then sbt = “milyar”
If (c = 11 ) Then sbt = “puluh”
End Function
Private Function nm(cx As String)
If (cx = “1″ ) Then nm = “satu”
If (cx = “2″ ) Then nm = “dua”
If (cx = “3″ ) Then nm = “tiga”
If (cx = “4″ ) Then nm = “empat”
If (cx = “5″ ) Then nm = “lima”
If (cx = “6″ ) Then nm = “enam”
If (cx = “7″ ) Then nm = “tujuh”
If (cx = “8″ ) Then nm = “delapan”
If (cx = “9″ ) Then nm = “sembilan”
If (cx = “0″ ) Then nm = “nol”
End Function
Function bilang(angka As String ) As String
Dim ang As Long
Dim bulat As String
Dim bul As Long
Dim x As Long
Dim pos As Long
Dim z As String
Dim w As String
Dim y As Long
Dim k1 As String
Dim k2 As String
Dim yy As Long
Dim ext As String
Dim stp As Long
Dim v As String
ang = Len( angka )
bulat = angka
bul = Len( bulat )
x = bul
stp = 0
Do While (x > 0 )
pos = bul – x + 1
z = Mid(bulat, pos, 1 )
w = Mid(bulat, pos )
y = Len(w)
If (z <> “0″ ) Then
‘jika angkanya bukan nol
If ( z = “1″ And ( y = 2 Or y = 5 Or y = 8 Or y = 11 ) ) Then
‘jika angka 1 dan merupakan puluhan, puluh ribu, puluh juta, puluh milyar
v = Mid(bulat, pos + 1, 1 )
If ( v = “1″ ) Then
‘ jika angka belakangnya = 1
k1 = “sebelas ”
yy = y – 1
k2 = sbt( y – 1 )
ElseIf (v = “0″ ) Then
‘jika angka belakangya = 0
k1 = “se”
k1 = k1 & sbt( y )
k1 = k1 & ” ” & sbt( y – 1 )
k2 = “”
Else
‘jika angka di belakngnya bukan 1 ataupun 0
k1 = nm( v ) & ” belas”
yy = y – 1
k2 = sbt( y – 1 )
End If
stp = 0
ext = k1 & ” ” & k2
x = x – 1
ElseIf ( z = “1″ And pos = 1 And ( y = 3 Or y = 4 Or y = 6 Or y = 9 ) ) Then
‘ jika angka 1 di posisi paling depan dan merupakan ratusan, ribuan, ratusan ribu, ratusan juta
k1 = “se”
k2 = sbt( y )
ext = k1 & k2
ElseIf ( z = “1″ And ( y = 3 Or y = 6 Or y = 9 ) And Mid(bulat, pos + 1, 1 ) = “0″ And Mid(bulat, pos + 2, 1) = “0″ ) Then
k1 = “se”
k2 = sbt( y ) & ” ” & sbt( y – 2 )
ext = k1 & k2
x = x – 2
ElseIf ( z = “1″ And ( y = 3 Or y = 6 Or y = 9 ) ) Then
‘ jika angka 1 di posisi ratusan, ratusan ribu, ratusan juta
k1 = “se”
k2 = sbt( y )
ext = k1 & k2
ElseIf ( z <> “1″ And ( y = 3 Or y = 6 Or y = 9 ) And Mid( bulat, pos + 1, 1 ) = “0″ And Mid(bulat, pos + 2, 1 ) = “0″ ) Then
‘jika buka angka 1 dan merupakan ratusan bulat, ratusan ribu bulat, ratusan juta bulat
k1 = nm(z)
k2 = sbt(y) & ” ” & sbt(y – 2)
ext = k1 & ” ” & k2
x = x – 2
ElseIf ( z <> “1″ And (y = 5 Or y = 8 Or y = 11 ) And Mid(bulat, pos + 1, 1 ) = “0″ ) Then
k1 = nm( z )
k2 = sbt(y) & ” ” & sbt( y – 1 )
ext = k1 & ” ” & k2
x = x – 1
Else
k1 = nm( z )
k2 = sbt( y )
ext = k1 & ” ” & k2
End If
ElseIf ( z = “0″ And ( y = 4 Or y = 7 Or y = 10 ) And stp = 0 ) Then
‘jika angka 0 dan merupakan ribuan, jutaan, milyaran
If (Mid( bulat, pos – 1, 1 ) <> 0 ) Then
ext = sbt( y )
End If
stp = 1
Else
ext = “”
End If
If (ext <> “” And bilang <> “” ) Then
bilang = bilang & ” ” & ext
ElseIf (ext <> “” And bilang = “” ) Then
bilang = ext
End If
x = x – 1
Loop
bilang = UCase(Mid(bilang, 1, 1 ) ) & Mid(bilang, 2 ) & ” rupiah”
End Function
Sub baru()
End Sub
=============================
agen togel terbesar dan terbaik indonesia klik4d yang sudah lama menemani anda bermain togel secara online, kami bandar togel dan togel online
ReplyDelete