Home, Forum diskusi, Chatting, Download


Membuat Program Mengeja Bilangan

Function SpellDigit(x)
Dim cRet As String
cRet = ""
Select Case x
Case 0: cRet = " ZERO"
Case 1: cRet = " ONE"
Case 2: cRet = " TWO"
Case 3: cRet = " THREE"
Case 4: cRet = " FOUR"
Case 5: cRet = " FIVE"
Case 6: cRet = " SIX"
Case 7: cRet = " SEVEN"
Case 8: cRet = " EIGHT"
Case 9: cRet = " NINE"
Case 10: cRet = " TEN"
Case 11: cRet = " ELEVEN"
Case 12: cRet = " TWELVE"
Case 13: cRet = " THIRTEEN"
Case 14: cRet = " FOURTEEN"
Case 15: cRet = " FIFTEEN"
Case 16: cRet = " SIXTEEN"
Case 17: cRet = " SEVENTEEN"
Case 18: cRet = " EIGHTEEN"
Case 19: cRet = " NINETEEN"
Case 20: cRet = " TWENTY"
Case 30: cRet = " THIRTY"
Case 40: cRet = " FOURTY"
Case 50: cRet = " FIFTY"
Case 60: cRet = " SIXTY"
Case 70: cRet = " SEVENTY"
Case 80: cRet = " EIGHTY"
Case 90: cRet = " NINETY"
Case 100: cRet = " ONE HUNDRED"
Case 200: cRet = " TWO HUNDRED"
Case 300: cRet = " THREE HUNDRED"
Case 400: cRet = " FOUR HUNDRED"
Case 500: cRet = " FIVE HUNDRED"
Case 600: cRet = " SIX HUNDRED"
Case 700: cRet = " SEVEN HUNDRED"
Case 800: cRet = " EIGHT HUNDRED"
Case 900: cRet = " NINE HUNDRED"
End Select
SpellDigit = cRet
End Function

Function SpellHundred(x)
Dim cRet As String
Dim n100 As Integer
Dim n10 As Integer
Dim n1 As Integer
cRet = ""
n100 = Int(x / 100) * 100
n10 = Int((x - n100) / 10) * 10
n1 = (x - n100 - n10)
If n100 > 0 Then
   cRet = SpellDigit(n100)
End If
If n10 > 0 Then
   If n10 = 10 Then
      cRet = cRet & SpellDigit(n10 + n1)
   Else
      cRet = cRet & SpellDigit(n10)
   End If
End If
If n1 > 0 And n10 <> 10 Then
   cRet = cRet & SpellDigit(n1)
End If
SpellHundred = cRet
End Function

Public Function SpellAmount(x)
Dim cRet As String
Dim n1000000 As Long
Dim n1000 As Long
Dim n1 As Integer
Dim n0 As Integer
On Error Resume Next
cRet = ""
n1000000 = Int(x / 1000000) * 1000000
n1000 = Int((x - n1000000) / 1000) * 1000
n1 = Int(x - n1000000 - n1000)
n0 = (x - n1000000 - n1000 - n1) * 100
If n1000000 > 0 Then
   cRet = SpellHundred(n1000000 / 1000000) & " MILLION"
End If
If n1000 > 0 Then
   cRet = cRet & SpellHundred(n1000 / 1000) & " THOUSAND"
End If
If n1 > 0 Then
   cRet = cRet & SpellHundred(n1)
End If
If n0 > 0 Then
   cRet = cRet & " AND CENTS" & SpellHundred(n0)
End If
SpellAmount = cRet & " ONLY"
End Function

PENTACOM, Jl. Samosir No. 21 Medan.
pentacom@yahoogroups.com


Dibuat  oleh hendra@indoprog.com
Medan - Sumatera Utara
Indonesia