I have a module to convert numbers (in positive value) into My Language (indonesian) words below: - Option Compare Database
-
-
Public Function ubah_terbilang(xbil As Double)
-
Dim nilai, i, j, k, hasil$, HasilAkhir$, Bilangan#, Digit, Rp$, Bil$
-
-
If IsNull(xbil) Then
-
ubah_terbilang = Null
-
Exit Function
-
End If
-
-
'pengelompokan
-
Dim Kel$(1 To 6), Angka$(1 To 9), Sat$(1 To 3)
-
Kel$(1) = "Biliun "
-
Kel$(2) = "Triliun "
-
Kel$(3) = "Miliar "
-
Kel$(4) = "Juta "
-
Kel$(5) = "Ribu "
-
Kel$(6) = ""
-
-
'data angka
-
Angka$(1) = "Satu "
-
Angka$(2) = "Dua "
-
Angka$(3) = "Tiga "
-
Angka$(4) = "Empat "
-
Angka$(5) = "Lima "
-
Angka$(6) = "Enam "
-
Angka$(7) = "Tujuh "
-
Angka$(8) = "Delapan "
-
Angka$(9) = "Sembilan "
-
-
'satuan
-
Sat$(1) = "Ratus "
-
Sat$(2) = "Puluh "
-
Sat$(3) = ""
-
-
'mulai
-
Bilangan# = Val(xbil)
-
HasilAkhir$ = ""
-
GoSub HitungHuruf
-
If hasil$ <> "" Then
-
HasilAkhir$ = hasil$ + "Rupiah"
-
End If
-
-
'hitung pecahan
-
Bilangan# = Fix((Bilangan# - Fix(Bilangan#) + 0.005) * 100#)
-
If Bilangan# > 0 Then
-
GoSub HitungHuruf
-
If hasil$ <> "" Then
-
HasilAkhir$ = HasilAkhir$ + " " + hasil$ + "Sen"
-
End If
-
End If
-
-
ubah_terbilang = HasilAkhir$
-
Exit Function
-
-
HitungHuruf:
-
Rp$ = Right$(String$(18, "0") + LTrim$(Str$(Fix(Bilangan#))), 18)
-
hasil$ = ""
-
-
If Val(Rp$) = 0 Then Return
-
-
'blg bulat
-
For i = 1 To 6
-
Bil$ = Mid$(Rp$, i * 3 - 2, 3)
-
-
If Val(Bil$) = 1 And i = 5 Then
-
hasil$ = hasil$ + "Seribu "
-
-
ElseIf Val(Bil$) <> 0 Then
-
For j = 1 To 3
-
Digit = Val(Mid$(Bil$, j, 1))
-
If j = 2 And Right$(Bil$, 2) = "10" Then
-
hasil$ = hasil$ + "Sepuluh "
-
Exit For
-
-
ElseIf j = 2 And Right$(Bil$, 2) = "11" Then
-
hasil$ = hasil$ + "Sebelas "
-
Exit For
-
-
ElseIf j = 2 And Mid$(Bil$, 2, 1) = "1" Then
-
hasil$ = hasil$ + Angka$(Val(Right$(Bil$, 1))) + "Belas "
-
Exit For
-
-
ElseIf Digit = 1 And j = 1 Then
-
hasil$ = hasil$ + "Seratus "
-
-
ElseIf Digit <> 0 Then
-
hasil$ = hasil$ + Angka$(Digit) + Sat$(j)
-
-
End If
-
Next
-
hasil$ = hasil$ + Kel$(i)
-
End If
-
Next
-
Return
-
End Function
-
When i type negative numbers, this module not works, example i type -100 the result is empty.
Please help me to modify this module when i type positive or negative value into field, this module can translate it to other field.
Thanks
Sure, I put that in there thinking that you are trying to include negative numbers in your display. Just remove line 55 from post #2.
So if you remove the negative notation, what do you expect the function to do when it is passed a negative number? ...How are negative number expressed in your language?
4 2016
This should/might be close. You'll have to update line 55 to add whatever is needed to the front or end to signify a negative number: - Option Compare Database
-
Option Explicit
-
-
-
Public Function ubah_terbilang(xbil As Double)
-
Dim nilai, i, j, k, hasil$, HasilAkhir$, Bilangan#, Digit, Rp$, Bil$
-
-
If IsNull(xbil) Then
-
ubah_terbilang = Null
-
Exit Function
-
End If
-
-
'pengelompokan
-
Dim Kel$(1 To 6), Angka$(1 To 9), Sat$(1 To 3)
-
Kel$(1) = "Biliun "
-
Kel$(2) = "Triliun "
-
Kel$(3) = "Miliar "
-
Kel$(4) = "Juta "
-
Kel$(5) = "Ribu "
-
Kel$(6) = ""
-
-
'data angka
-
Angka$(1) = "Satu "
-
Angka$(2) = "Dua "
-
Angka$(3) = "Tiga "
-
Angka$(4) = "Empat "
-
Angka$(5) = "Lima "
-
Angka$(6) = "Enam "
-
Angka$(7) = "Tujuh "
-
Angka$(8) = "Delapan "
-
Angka$(9) = "Sembilan "
-
-
'satuan
-
Sat$(1) = "Ratus "
-
Sat$(2) = "Puluh "
-
Sat$(3) = ""
-
-
'mulai
-
Bilangan# = Val(xbil)
-
HasilAkhir$ = ""
-
GoSub HitungHuruf
-
If hasil$ <> "" Then
-
HasilAkhir$ = hasil$ + "Rupiah"
-
End If
-
-
'hitung pecahan
-
Bilangan# = Fix((Bilangan# - Fix(Bilangan#) + 0.005) * 100#)
-
If Bilangan# > 0 Then
-
GoSub HitungHuruf
-
If hasil$ <> "" Then
-
HasilAkhir$ = HasilAkhir$ + " " + hasil$ + "Sen"
-
End If
-
End If
-
-
If xbil < 0 Then HasilAkhir$ = "Negative " & HasilAkhir$ -
ubah_terbilang = HasilAkhir$
-
Exit Function
-
-
HitungHuruf:
-
Rp$ = Right$(String$(18, "0") + LTrim$(Str$(Fix(Abs(Bilangan#)))), 18) -
hasil$ = ""
-
-
If Val(Rp$) = 0 Then Return
-
-
'blg bulat
-
For i = 1 To 6
-
Bil$ = Mid$(Rp$, i * 3 - 2, 3)
-
-
If Val(Bil$) = 1 And i = 5 Then
-
hasil$ = hasil$ + "Seribu "
-
-
ElseIf Val(Bil$) <> 0 Then
-
For j = 1 To 3
-
Digit = Val(Mid$(Bil$, j, 1))
-
If j = 2 And Right$(Bil$, 2) = "10" Then
-
hasil$ = hasil$ + "Sepuluh "
-
Exit For
-
-
ElseIf j = 2 And Right$(Bil$, 2) = "11" Then
-
hasil$ = hasil$ + "Sebelas "
-
Exit For
-
-
ElseIf j = 2 And Mid$(Bil$, 2, 1) = "1" Then
-
hasil$ = hasil$ + Angka$(Val(Right$(Bil$, 1))) + "Belas "
-
Exit For
-
-
ElseIf Digit = 1 And j = 1 Then
-
hasil$ = hasil$ + "Seratus "
-
-
ElseIf Digit <> 0 Then
-
hasil$ = hasil$ + Angka$(Digit) + Sat$(j)
-
-
End If
-
Next
-
hasil$ = hasil$ + Kel$(i)
-
End If
-
Next
-
Return
-
End Function
-
Thanks Jforbes, its work, but the "negative" word is now show in the field, like picture attached, can it be removed?
Sure, I put that in there thinking that you are trying to include negative numbers in your display. Just remove line 55 from post #2.
So if you remove the negative notation, what do you expect the function to do when it is passed a negative number? ...How are negative number expressed in your language?
It's done now. I'm making a receipt from this database. Negative number for debit transaction so I can count each group report with sum function not (group a - group b) because there is no standard function for that. Thanks jforbes
Sign in to post your reply or Sign up for a free account.
Similar topics
by: pj |
last post by:
Why does M$ Query Analyzer display all numbers as positive, no matter
whether they are truly positive or negative ?
I am having to cast each column to varchar to find out if there are
any...
|
by: Charles A. Lackman |
last post by:
Hello,
I have some textboxes that are doing addition:
Dim AString As Double
AString = Convert.ToDouble(TextBox1.Text) - Convert.To(DoubleTextBox2.Text)
TextBox3.Text =...
|
by: Bob Bryan |
last post by:
I am using a select statement to obtain a result set back with aggregated
data. The problem is that I am seeing column data with 11 to 13 digits
after the decimal point. I tried using the STR...
|
by: Angus Comber |
last post by:
Hello
Sorry this really is a newbie question!
I am doing some floating point arithmetic and calculating the time
difference between two dates. The date values being comparied are actually...
|
by: tlyczko |
last post by:
Hello Rob B posted this wonderful code in another thread,
http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/c84d8538025980dd/6ead9d5e61be85f0#6ead9d5e61be85f0
I could not...
|
by: Frederick Gotham |
last post by:
I have a general idea about how negative number systems work, but I'd
appreciate some clarification if anyone would be willing to help me.
Let's assume we're working with an 8-Bit signed integer,...
|
by: venkat.yara |
last post by:
Hi everybody i am new to this group i want to clarify my doubt that
how can i write a program that converts corrency from digits to words
is there any function.
example if i enter 5430 . output...
|
by: Casey |
last post by:
Is there an easy way to use getopt and still allow negative numbers as
args? I can easily write a workaround (pre-process the tail end of
the arguments, stripping off any non-options including...
|
by: vivek kushwaha |
last post by:
Hi guys,
I need codes to convert Currency into Words. e.g.
120,500 into "One Lac. Five hundred only."
in asp.net with vb.net 1.1.
Please if anybody know about it. Reply me.
Vivek.
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |