2 Messages
Digest #2763
Messages
Mon Aug 25, 2014 7:02 am (PDT) . Posted by:
"Edhie Wibowo" edhiewibowo
Dear temans,
saya mau tanya nih, ttg macro penulisan bilangan utk uang (rupiah),
dapet dari google dalam dollar, kemudian saya modifikasi jadi rupiah.
Sejauh ini sih macronya berhasil dgn baik, hanya ketika ada angka 100,
tidak bisa membacanya "seratus" tapi satu ratus, juga 10, tidak dibaca
"sepuluh", tapi satu puluh. Gimana spy bisa terbaca cara Indonesia?
Mohon solusinya dari para master. Terima kasih banyak.
-------------------------------------------
Option Explicit
'Main Function
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " ribu "
Place(3) = " juta "
Place(4) = " milyar "
Place(5) = " trilyun "
' String representation of amount.
MyNumber = Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = "Tidak ada uang"
Case "One"
Dollars = "satu rupiah"
Case Else
Dollars = Dollars & " rupiah"
End Select
Select Case Cents
Case ""
Cents = " "
Case "One"
Cents = " dan satu sen"
Case Else
Cents = " and " & Cents & " sen"
End Select
SpellNumber = Dollars & Cents
End Function
' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " ratus "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function
' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "sepuluh"
Case 11: Result = "sebelas"
Case 12: Result = "dua belas"
Case 13: Result = "tiga belas"
Case 14: Result = "empat belas"
Case 15: Result = "lima belas"
Case 16: Result = "enam belas"
Case 17: Result = "tujuh belas"
Case 18: Result = "Delapan Belas"
Case 19: Result = "Sembilan Belas"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "dua puluh "
Case 3: Result = "tiga puluh "
Case 4: Result = "empat puluh "
Case 5: Result = "lima puluh "
Case 6: Result = "enam puluh "
Case 7: Result = "tujuh puluh "
Case 8: Result = "delapan puluh "
Case 9: Result = "sembilan puluh "
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function
' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "satu"
Case 2: GetDigit = "dua"
Case 3: GetDigit = "tiga"
Case 4: GetDigit = "empat"
Case 5: GetDigit = "lima"
Case 6: GetDigit = "enam"
Case 7: GetDigit = "tujuh"
Case 8: GetDigit = "delapan"
Case 9: GetDigit = "sembilan"
Case Else: GetDigit = ""
End Select
End Function
----------------------------------------------------------
--
Jabat hangat,
Edhie Wibowo
"Vision Shows the Way, Passion Sustains the Journey"
saya mau tanya nih, ttg macro penulisan bilangan utk uang (rupiah),
dapet dari google dalam dollar, kemudian saya modifikasi jadi rupiah.
Sejauh ini sih macronya berhasil dgn baik, hanya ketika ada angka 100,
tidak bisa membacanya "seratus" tapi satu ratus, juga 10, tidak dibaca
"sepuluh"
Mohon solusinya dari para master. Terima kasih banyak.
------------
Option Explicit
'Main Function
Function SpellNumber(
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " ribu "
Place(3) = " juta "
Place(4) = " milyar "
Place(5) = " trilyun "
' String representation of amount.
MyNumber = Trim(Str(MyNumber)
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, "."
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(
"00"
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = "Tidak ada uang"
Case "One"
Dollars = "satu rupiah"
Case Else
Dollars = Dollars & " rupiah"
End Select
Select Case Cents
Case ""
Cents = " "
Case "One"
Cents = " dan satu sen"
Case Else
Cents = " and " & Cents & " sen"
End Select
SpellNumber = Dollars & Cents
End Function
' Converts a number from 100-999 into text
Function GetHundreds(
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> "0" Then
Result = GetDigit(Mid(
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(
Else
Result = Result & GetDigit(Mid(
End If
GetHundreds = Result
End Function
' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "sepuluh"
Case 11: Result = "sebelas"
Case 12: Result = "dua belas"
Case 13: Result = "tiga belas"
Case 14: Result = "empat belas"
Case 15: Result = "lima belas"
Case 16: Result = "enam belas"
Case 17: Result = "tujuh belas"
Case 18: Result = "Delapan Belas"
Case 19: Result = "Sembilan Belas"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "dua puluh "
Case 3: Result = "tiga puluh "
Case 4: Result = "empat puluh "
Case 5: Result = "lima puluh "
Case 6: Result = "enam puluh "
Case 7: Result = "tujuh puluh "
Case 8: Result = "delapan puluh "
Case 9: Result = "sembilan puluh "
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function
' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "satu"
Case 2: GetDigit = "dua"
Case 3: GetDigit = "tiga"
Case 4: GetDigit = "empat"
Case 5: GetDigit = "lima"
Case 6: GetDigit = "enam"
Case 7: GetDigit = "tujuh"
Case 8: GetDigit = "delapan"
Case 9: GetDigit = "sembilan"
Case Else: GetDigit = ""
End Select
End Function
------------
--
Jabat hangat,
Edhie Wibowo
"Vision Shows the Way, Passion Sustains the Journey"
Mon Aug 25, 2014 7:03 am (PDT) . Posted by:
girlsaye@ymail.com
Dear para pakar excell mania,
Mohon dibantu saya untuk memecahkan case sbb.
Misal No rekenening : 0056-27-45-12345
Dari data no rekening tsb di atas bagaimana sy menghilangkan karakter minus (-) tanpa menghilangakan karakter depan (0056). Karena sy sdh mencoba menggunakan control replace untuk menghilang karakter (-), tetapi karakter yg didepan juga ikut hilang (angaka 00). Atas bantuannya, sy sampaikan terima kasih
Regards
Ningrum
Powered by Telkomsel BlackBerry®
Mohon dibantu saya untuk memecahkan case sbb.
Misal No rekenening : 0056-27-45-12345
Dari data no rekening tsb di atas bagaimana sy menghilangkan karakter minus (-) tanpa menghilangakan karakter depan (0056). Karena sy sdh mencoba menggunakan control replace untuk menghilang karakter (-), tetapi karakter yg didepan juga ikut hilang (angaka 00). Atas bantuannya, sy sampaikan terima kasih
Regards
Ningrum
Powered by Telkomsel BlackBerry®
:: XL-mania ::::::::::::::::::::
Momods sekarang jualan tas di www.flirtypoodle.com ha ha ha....
:: ------------- ::::::::::::::::::::
DILARANG : MLM, money game, OOT, iklan tanpa izin, SARA, testing, pembicaraan pribadi, one line message, melecehkan, tidak sopan.
:: ------------- ::::::::::::::::::::
Buat subjek yang kreatif, jangan : "tanya", "help", "mohon bantu"
Usahakan besar attachment < 200 kb. Gunakan winzip jika perlu.
:: ------------- ::::::::::::::::::::
Ajak teman-teman Anda bergabung dengan mengirim e-mail kosong ke
XL-mania-subscribe@yahoogroups.com atau kirimkan mereka file dari
http://groups.yahoo.com/group/XL-mania/files/Promotion/
:: ------------- ::::::::::::::::::::
Berikan testimoni di :
http://www.xl-mania.com/2008/06/testimoni-xl-mania.html
:: ------------- ::::::::::::::::::::
Message lama ada di :
http://groups.yahoo.com/group/XL-mania/messages [perlu yahoo id]
http://www.mail-archive.com/xl-mania@yahoogroups.com
Momods sekarang jualan tas di www.flirtypoodle.com ha ha ha....
:: ------------- ::::::::::::::::::::
DILARANG : MLM, money game, OOT, iklan tanpa izin, SARA, testing, pembicaraan pribadi, one line message, melecehkan, tidak sopan.
:: ------------- ::::::::::::::::::::
Buat subjek yang kreatif, jangan : "tanya", "help", "mohon bantu"
Usahakan besar attachment < 200 kb. Gunakan winzip jika perlu.
:: ------------- ::::::::::::::::::::
Ajak teman-teman Anda bergabung dengan mengirim e-mail kosong ke
XL-mania-subscribe@yahoogroups.com atau kirimkan mereka file dari
http://groups.yahoo.com/group/XL-mania/files/Promotion/
:: ------------- ::::::::::::::::::::
Berikan testimoni di :
http://www.xl-mania.com/2008/06/testimoni-xl-mania.html
:: ------------- ::::::::::::::::::::
Message lama ada di :
http://groups.yahoo.com/group/XL-mania/messages [perlu yahoo id]
http://www.mail-archive.com/xl-mania@yahoogroups.com
Tidak ada komentar:
Posting Komentar