473,568 Members | 2,963 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 29192
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
2955
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
59414
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...
2
1346
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
1725
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...
2
4216
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...
5
3648
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
4876
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,...
2
1582
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...
1
12465
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
7690
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...
0
7909
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8115
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...
0
6273
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5216
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...
0
3649
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...
1
1206
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
930
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...

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.