Dim kata(1 To 9) As String

Private Sub Form_Load()

kata(1) = "Satu "
kata(2) = "Dua "
kata(3) = "Tiga "
kata(4) = "Empat "
kata(5) = "Lima "
kata(6) = "Enam "
kata(7) = "Tujuh "
kata(8) = "Delapan "
kata(9) = "Sembilan "

End Sub


Function sebut(x)

Dim a, b, c As Integer
Dim teks1 As String

a = x \ 100
b = (x \ 10) Mod 10
c = x Mod 10

If a > 0 Then
If a = 1 Then
teks1 = "Seratus "
Else
teks1 = teks1 & kata(a) & "Ratus "
End If
End If

If b > 0 Then
If b = 1 Then
If c = 0 Then
teks1 = teks1 & "Sepuluh "
ElseIf c = 1 Then
teks1 = teks1 & "Sebelas "
c = 0
Else
teks1 = teks1 & kata(c) & "Belas "
c = 0
End If
Else
teks1 = teks1 & kata(b) & "Puluh "
End If
End If

If c > 0 Then teks1 = teks1 & kata(c)
sebut = teks1

End Function


Private Sub txttitip_KeyPress(KeyAscii As Integer)
Dim a, b, c As Integer
Dim teks1 As String
Dim angka As Long

If KeyAscii = 13 Then
angka = Val(txttotal.Text)
a = angka \ 1000000
b = (angka \ 1000) Mod 1000
c = angka Mod 1000
If a > 0 Then
teks1 = teks1 & sebut(a) & "Juta "
End If

If b > 0 Then
If b = 1 Then
teks1 = teks1 & "Seribu "
Else
teks1 = teks1 & sebut(b) & "Ribu "
End If

End If
If c > 0 Then teks1 = teks1 & sebut(c)
txtbilang.Text = teks1 & "Rupiah"
End If
End Sub

0 comments

Post a Comment



Subscribe to: Post Comments (Atom)