How to write amount in words
-
Dear All I need your direction how to say an amount in words in visual absic.net program language, for the detail I will give an ilustration as follow: I would like my program can automatically write 1,000,000.00 to be "one million and zero cent" in words. Could any body from can help me ho to do that Thank you for your help in advance Best regards :doh:
ICE
-
Dear All I need your direction how to say an amount in words in visual absic.net program language, for the detail I will give an ilustration as follow: I would like my program can automatically write 1,000,000.00 to be "one million and zero cent" in words. Could any body from can help me ho to do that Thank you for your help in advance Best regards :doh:
ICE
That's the ubiquitous homework assignment. All you have to do is type "convert number to words" into Yahoo or Google and you'll come up with millions of hits.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Dear All I need your direction how to say an amount in words in visual absic.net program language, for the detail I will give an ilustration as follow: I would like my program can automatically write 1,000,000.00 to be "one million and zero cent" in words. Could any body from can help me ho to do that Thank you for your help in advance Best regards :doh:
ICE
This is a common homework problem, I'm sure there's code to be found to do it. Essentially, you just parse the parts of the number and build your text representation of it.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
That's the ubiquitous homework assignment. All you have to do is type "convert number to words" into Yahoo or Google and you'll come up with millions of hits.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Dave Kreskowiak wrote:
ubiquitous homework assignment
I remember those kind of assignments from a long, long, long time ago :-D
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
-
Dear All I need your direction how to say an amount in words in visual absic.net program language, for the detail I will give an ilustration as follow: I would like my program can automatically write 1,000,000.00 to be "one million and zero cent" in words. Could any body from can help me ho to do that Thank you for your help in advance Best regards :doh:
ICE
Here's something i found, might help you.
=SpellNumber(32.50)
Option Explicit '**************** ' Main Function * '**************** Function SpellNumber(ByVal MyNumber) Dim Dollars, Cents, Temp Dim DecimalPlace, Count ReDim Place(9) As String Place(2) = " Thousand " Place(3) = " Million " Place(4) = " Billion " Place(5) = " Trillion " ' 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 = "No Dollars" Case "One" Dollars = "One Dollar" Case Else Dollars = Dollars & " Dollars" End Select Select Case Cents Case "" Cents = " and No Cents" Case "One" Cents = " and One Cent" Case Else Cents = " and " & Cents & " Cents" 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)) & " Hundred " 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
-
Dear All I need your direction how to say an amount in words in visual absic.net program language, for the detail I will give an ilustration as follow: I would like my program can automatically write 1,000,000.00 to be "one million and zero cent" in words. Could any body from can help me ho to do that Thank you for your help in advance Best regards :doh:
ICE
There is an example right here on Code Project. It walks you through the entire process of creating the code so you know exactly what is going on and how it is built up. It also shows you how to test the code too (a skill far too few developers actually know how to do) http://www.codeproject.com/cs/design/TestFirstDevelopment.asp[^]
Upcoming FREE developer events: * Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website
-
Here's something i found, might help you.
=SpellNumber(32.50)
Option Explicit '**************** ' Main Function * '**************** Function SpellNumber(ByVal MyNumber) Dim Dollars, Cents, Temp Dim DecimalPlace, Count ReDim Place(9) As String Place(2) = " Thousand " Place(3) = " Million " Place(4) = " Billion " Place(5) = " Trillion " ' 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 = "No Dollars" Case "One" Dollars = "One Dollar" Case Else Dollars = Dollars & " Dollars" End Select Select Case Cents Case "" Cents = " and No Cents" Case "One" Cents = " and One Cent" Case Else Cents = " and " & Cents & " Cents" 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)) & " Hundred " 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
Wow. I'm unimpressed. You've managed to do all of his work for him, for an obvious homewrok assignment. Congratulations on helping him fail the class.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Wow. I'm unimpressed. You've managed to do all of his work for him, for an obvious homewrok assignment. Congratulations on helping him fail the class.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
The most valuable skill you can have as a developer is to know how to do your own research. You absolutely must be able to find out anything you need to to teach yourself anything from new techniques to entirely new technologies. Without that ability, you'd last about a year in a career writing code, if not any computer career. There are three points to be made with every programming project in a class. 1. How do you logically break the problem down into smaller and smaller parts and code solutions to those small problems that work together. 2. How you manage your time to accomplish the task in the given time frame. 3. And how you do the research to teach yourself about the parts you're stuck on. This includes books, internet search engines and sites, and asking for help from appropriate resources by asking the proper questions. Showing up on a site and asking for someone to hand over the entire source code is NOT the proper question. It just bypasses the other two points completely. He really didn't ask for the source code, but he couldn't do point number 1 either. The answer he got pointed him in the correct direction to start doing his own research into the problem.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Here's something i found, might help you.
=SpellNumber(32.50)
Option Explicit '**************** ' Main Function * '**************** Function SpellNumber(ByVal MyNumber) Dim Dollars, Cents, Temp Dim DecimalPlace, Count ReDim Place(9) As String Place(2) = " Thousand " Place(3) = " Million " Place(4) = " Billion " Place(5) = " Trillion " ' 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 = "No Dollars" Case "One" Dollars = "One Dollar" Case Else Dollars = Dollars & " Dollars" End Select Select Case Cents Case "" Cents = " and No Cents" Case "One" Cents = " and One Cent" Case Else Cents = " and " & Cents & " Cents" 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)) & " Hundred " 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
Thank you for your attention and your direction to me, I will trying to use of your valuable inforamtion Thank you:-D
ICE