ConvertCurrencyToEnglish

gwidijanto

Registered User.
Local time
Today, 03:48
Joined
May 4, 2003
Messages
28
Hi all,
I'm new in here, also new with Access and now try to learn VBA to handle my Access application.
I have a problem with this user-defined function named ConvertCurrencyToEnglish. It's convert a numeric value to an English word representation. For example, the function will return the following words for the number 1234.56:
One Thousand Two Hundred Thirty Four Dollars And Fifty Six Cents.

http://support.microsoft.com/defaul...pport/KB/Articles/Q95/6/40.asp&NoWebContent=1

the problem is: I live in Indonesia and we spell "one hundred" and "one thousand" is slightly different, we spell it in one word, so it become like this: "ahundred" and "athousand".
I have difficulty trying to insert a function to find "one hundred" and converted it to "ahundred" also for "athousand".

I greatly appreciate if somebody can help me to solve this problem?
Thankyou very much.
 
A quick-fix might be a short function which takes the "One thousand" output and converts it to your format. Copy/paste the following code to a new module and follow the instructions for testing.
Code:
Function FixStr(strTot As String) As String
'*******************************************
'Name:      FixStr (Function)
'Purpose:   Make specific language changes
'           to an amount expressed as text.
'Inputs:    From the debug window:
'? fixstr("One Thousand One Hundred Thirty Four Dollars And Fifty Six Cents")
'Output:    Athousand Ahundred Thirty Four Dollars And Fifty Six Cents
'*******************************************

Dim strHold As String
Dim i As Integer, n As Integer, l As Integer

strHold = strTot
For i = 1 To 2
   n = InStr(strHold, Choose(i, "One Thousand", "One Hundred"))
   l = Len(Choose(i, "One Thousand", "One Hundred"))
If n > 0 Then
   strHold = Left(strHold, n - 1) & Choose(i, "Athousand", "Ahundred") & Mid(strHold, n + l)
End If
Next i
FixStr = strHold
   
End Function
 
Hi raskew,
It works! Thankyou verymuch.
 
Hey, I'm glad it worked for you.

What really amazes me is that this, and any forum, is communicating half-way around the world. I just find that awesome.

Best wishes,

Bob
 

Users who are viewing this thread

Back
Top Bottom