473,721 Members | 3,997 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CONVERT Amount to Words

I want to convert amount to words. Is there any funciton available?

Example:
$230.30

Two Hundred Thirty Dollars and 30/100
Nov 21 '05 #1
7 29240
Pick up the code from here . . . ( vba but you can use it ).

http://support.microsoft.com/default...b;en-us;213360
Terry Burns : http://TrainingOn.net

--------------------------------------------------------------------

"patang" <pa****@discuss ions.microsoft. com> wrote in message
news:93******** *************** ***********@mic rosoft.com...
I want to convert amount to words. Is there any funciton available?

Example:
$230.30

Two Hundred Thirty Dollars and 30/100

Nov 21 '05 #2
In English In VB6 code (nicely done easy to change)

http://support.microsoft.com/?scid=h...s/Q95/6/40.ASP

I hope this helps,

Cor
Nov 21 '05 #3
Do you know if it is available for VB.Net also?

"OHM ( Terry Burns )" wrote:
Pick up the code from here . . . ( vba but you can use it ).

http://support.microsoft.com/default...b;en-us;213360
Terry Burns : http://TrainingOn.net

--------------------------------------------------------------------

"patang" <pa****@discuss ions.microsoft. com> wrote in message
news:93******** *************** ***********@mic rosoft.com...
I want to convert amount to words. Is there any funciton available?

Example:
$230.30

Two Hundred Thirty Dollars and 30/100


Nov 21 '05 #4
Do you know if it is available for VB.Net also?

"Cor Ligthert" wrote:
In English In VB6 code (nicely done easy to change)

http://support.microsoft.com/?scid=h...s/Q95/6/40.ASP

I hope this helps,

Cor

Nov 21 '05 #5
> Do you know if it is available for VB.Net also?

Would I than have sent you this. However the needed changes are in this
minimal.

Cor
Nov 21 '05 #6
Below is the VB.Net code. As Cor said, the changes were minimal...it took me
5min or less the modify it.

Public Function ConvertCurrency ToEnglish(ByVal MyNumber As Double) As String
Dim Temp As String
Dim Dollars, Cents As String
Dim DecimalPlace, Count As Integer
Dim Place(9) As String
Dim Numb As String
Place(2) = " Thousand " : Place(3) = " Million " : Place(4) = "
Billion " : Place(5) = " Trillion "
' Convert Numb to a string, trimming extra spaces.
Numb = Trim(Str(MyNumb er))
' Find decimal place.
DecimalPlace = InStr(Numb, ".")
' If we find decimal place...
If DecimalPlace > 0 Then
' Convert cents
Temp = Left(Mid(Numb, DecimalPlace + 1) & "00", 2)
Cents = ConvertTens(Tem p)
' Strip off cents from remainder to convert.
Numb = Trim(Left(Numb, DecimalPlace - 1))
End If
Count = 1
Do While Numb <> ""
' Convert last 3 digits of Numb to English dollars.
Temp = ConvertHundreds (Right(Numb, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(Numb) > 3 Then
' Remove last 3 converted digits from Numb.
Numb = Left(Numb, Len(Numb) - 3)
Else
Numb = ""
End If
Count = Count + 1
Loop

' Clean up dollars.
Select Case Dollars
Case "" : Dollars = "No Dollars"
Case "One" : Dollars = "One Dollar"
Case Else : Dollars = Dollars & " Dollars"
End Select

' Clean up cents.
Select Case Cents
Case "" : Cents = " And No Cents"
Case "One" : Cents = " And One Cent"
Case Else : Cents = " And " & Cents & " Cents"
End Select
ConvertCurrency ToEnglish = Dollars & Cents
End Function

Private Function ConvertHundreds (ByVal MyNumber As String) As String
Dim Result As String
' Exit if there is nothing to convert.
If Val(MyNumber) = 0 Then Exit Function
' Append leading zeros to number.
MyNumber = Right("000" & MyNumber, 3)
' Do we have a hundreds place digit to convert?
If Left(MyNumber, 1) <> "0" Then
Result = ConvertDigit(Le ft(MyNumber, 1)) & " Hundred "
End If
' Do we have a tens place digit to convert?
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & ConvertTens(Mid (MyNumber, 2))
Else
' If not, then convert the ones place digit.
Result = Result & ConvertDigit(Mi d(MyNumber, 3))
End If
ConvertHundreds = Trim(Result)
End Function

Private Function ConvertTens(ByV al MyTens As String) As String
Dim Result As String
' Is value between 10 and 19?
If Val(Left(MyTens , 1)) = 1 Then
Select Case Val(MyTens)
Case 10 : Result = "Ten"
Case 11 : Result = "Eleven"
Case 12 : Result = "Twelve"
Case 13 : Result = "Thirteen"
Case 14 : Result = "Fourteen"
Case 15 : Result = "Fifteen"
Case 16 : Result = "Sixteen"
Case 17 : Result = "Seventeen"
Case 18 : Result = "Eighteen"
Case 19 : Result = "Nineteen"
Case Else
End Select
Else
' .. otherwise it's between 20 and 99.
Select Case Val(Left(MyTens , 1))
Case 2 : Result = "Twenty "
Case 3 : Result = "Thirty "
Case 4 : Result = "Forty "
Case 5 : Result = "Fifty "
Case 6 : Result = "Sixty "
Case 7 : Result = "Seventy "
Case 8 : Result = "Eighty "
Case 9 : Result = "Ninety "
Case Else
End Select
' Convert ones place digit.
Result = Result & ConvertDigit(Ri ght(MyTens, 1))
End If
ConvertTens = Result
End Function

Private Function ConvertDigit(By Val MyDigit As String) As String
Select Case Val(MyDigit)
Case 1 : ConvertDigit = "One"
Case 2 : ConvertDigit = "Two"
Case 3 : ConvertDigit = "Three"
Case 4 : ConvertDigit = "Four"
Case 5 : ConvertDigit = "Five"
Case 6 : ConvertDigit = "Six"
Case 7 : ConvertDigit = "Seven"
Case 8 : ConvertDigit = "Eight"
Case 9 : ConvertDigit = "Nine"
Case Else : ConvertDigit = ""
End Select
End Function
"patang" wrote:
Do you know if it is available for VB.Net also?

"Cor Ligthert" wrote:
In English In VB6 code (nicely done easy to change)

http://support.microsoft.com/?scid=h...s/Q95/6/40.ASP

I hope this helps,

Cor

Nov 21 '05 #7
Below is the VB.Net code. As Cor said, the changes were minimal...it took me
5min or less the modify it.

Public Function ConvertCurrency ToEnglish(ByVal MyNumber As Double) As String
Dim Temp As String
Dim Dollars, Cents As String
Dim DecimalPlace, Count As Integer
Dim Place(9) As String
Dim Numb As String
Place(2) = " Thousand " : Place(3) = " Million " : Place(4) = "
Billion " : Place(5) = " Trillion "
' Convert Numb to a string, trimming extra spaces.
Numb = Trim(Str(MyNumb er))
' Find decimal place.
DecimalPlace = InStr(Numb, ".")
' If we find decimal place...
If DecimalPlace > 0 Then
' Convert cents
Temp = Left(Mid(Numb, DecimalPlace + 1) & "00", 2)
Cents = ConvertTens(Tem p)
' Strip off cents from remainder to convert.
Numb = Trim(Left(Numb, DecimalPlace - 1))
End If
Count = 1
Do While Numb <> ""
' Convert last 3 digits of Numb to English dollars.
Temp = ConvertHundreds (Right(Numb, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(Numb) > 3 Then
' Remove last 3 converted digits from Numb.
Numb = Left(Numb, Len(Numb) - 3)
Else
Numb = ""
End If
Count = Count + 1
Loop

' Clean up dollars.
Select Case Dollars
Case "" : Dollars = "No Dollars"
Case "One" : Dollars = "One Dollar"
Case Else : Dollars = Dollars & " Dollars"
End Select

' Clean up cents.
Select Case Cents
Case "" : Cents = " And No Cents"
Case "One" : Cents = " And One Cent"
Case Else : Cents = " And " & Cents & " Cents"
End Select
ConvertCurrency ToEnglish = Dollars & Cents
End Function

Private Function ConvertHundreds (ByVal MyNumber As String) As String
Dim Result As String
' Exit if there is nothing to convert.
If Val(MyNumber) = 0 Then Exit Function
' Append leading zeros to number.
MyNumber = Right("000" & MyNumber, 3)
' Do we have a hundreds place digit to convert?
If Left(MyNumber, 1) <> "0" Then
Result = ConvertDigit(Le ft(MyNumber, 1)) & " Hundred "
End If
' Do we have a tens place digit to convert?
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & ConvertTens(Mid (MyNumber, 2))
Else
' If not, then convert the ones place digit.
Result = Result & ConvertDigit(Mi d(MyNumber, 3))
End If
ConvertHundreds = Trim(Result)
End Function

Private Function ConvertTens(ByV al MyTens As String) As String
Dim Result As String
' Is value between 10 and 19?
If Val(Left(MyTens , 1)) = 1 Then
Select Case Val(MyTens)
Case 10 : Result = "Ten"
Case 11 : Result = "Eleven"
Case 12 : Result = "Twelve"
Case 13 : Result = "Thirteen"
Case 14 : Result = "Fourteen"
Case 15 : Result = "Fifteen"
Case 16 : Result = "Sixteen"
Case 17 : Result = "Seventeen"
Case 18 : Result = "Eighteen"
Case 19 : Result = "Nineteen"
Case Else
End Select
Else
' .. otherwise it's between 20 and 99.
Select Case Val(Left(MyTens , 1))
Case 2 : Result = "Twenty "
Case 3 : Result = "Thirty "
Case 4 : Result = "Forty "
Case 5 : Result = "Fifty "
Case 6 : Result = "Sixty "
Case 7 : Result = "Seventy "
Case 8 : Result = "Eighty "
Case 9 : Result = "Ninety "
Case Else
End Select
' Convert ones place digit.
Result = Result & ConvertDigit(Ri ght(MyTens, 1))
End If
ConvertTens = Result
End Function

Private Function ConvertDigit(By Val MyDigit As String) As String
Select Case Val(MyDigit)
Case 1 : ConvertDigit = "One"
Case 2 : ConvertDigit = "Two"
Case 3 : ConvertDigit = "Three"
Case 4 : ConvertDigit = "Four"
Case 5 : ConvertDigit = "Five"
Case 6 : ConvertDigit = "Six"
Case 7 : ConvertDigit = "Seven"
Case 8 : ConvertDigit = "Eight"
Case 9 : ConvertDigit = "Nine"
Case Else : ConvertDigit = ""
End Select
End Function
"patang" wrote:
Do you know if it is available for VB.Net also?

"Cor Ligthert" wrote:
In English In VB6 code (nicely done easy to change)

http://support.microsoft.com/?scid=h...s/Q95/6/40.ASP

I hope this helps,

Cor

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2964
by: Klaus Neuner | last post by:
Hello, I need a function that converts a list into a set of regexes. Like so: string_list = print string_list2regexes(string_list) This should return something like:
4
59425
by: meh | last post by:
I have imported data from excel file. When data came to SQL table, the type of AMOUNT column was varchar. I tried to convert and cast amount type of amount column to number type but it does not allow me to convert. What is the best way of importing data into SQL and type stays the same as it was in excel file ? Or anyone has any better solution, please let me. Thanks.
2
1353
by: TaeHo Yoo | last post by:
I have a column called "Amount" and this field contains amount as cents. So when I get the values of it, I do like "select amount / 100 as amount" which basically ignores cents. Do you know how to get cents? Thanks a lot *** Sent via Developersdex http://www.developersdex.com ***
3
1734
by: Hughsie | last post by:
Hi I am looking for code to convert a given currency amount (i.e. 321654.85) to the equivalent words (i.e. three hundred and twenty one thousand, six hundred and fifty four pounsd and eighty five pence). I have trawled the web and have found a few but haven't found anything which fits my needs. I need it to include 'and' in the relevant places to make good English and I also need the decimals converted.
2
4238
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with this. Also - the citrix folks do not want us to keep the FE in Access as the queries and other activities consume a lot of power. The users will be in 3 different offices across the globe all accessing the 1 Oracle DB in Citrix. Does anyone have...
5
3665
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 should be : five thousand four hundred thirty
2
4888
by: nineballssj9 | last post by:
#include <stdio.h> #include <string.h> #include <math.h> //i'm trying to convert number into word like for an example if i type //99.99 then it will print ninety nine point ninety nine //can anybody please help me //i have a parse error that i cant figure out int values = { 90, 80, 70, 60, 50, 40, 30, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
2
1594
by: jorge | last post by:
I know this is old and I am sorry to ask but since the company block the access to the port 80 we have only newsgroup access (witch still is very good!) simple question I need a procedure or function that return me a amount in words and accept an amount value; like the one that we use for writing checks. if someone has the rutine please help me with it. thanks and sorry again. George
1
12501
by: magz123 | last post by:
guyz.. Is there any function in vb6 to convert amount in digits to amount in words...like e.g from Rs.450 to four hundred and fifty ... if anyone knows reply to it as soon as possible..
0
8852
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9227
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5992
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4761
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3206
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2590
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2143
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.