Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to write amount in words

How to write amount in words

Scheduled Pinned Locked Moved Visual Basic
csharphelptutorial
10 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Swiss Mantoro
    wrote on last edited by
    #1

    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

    D C P C 4 Replies Last reply
    0
    • S Swiss Mantoro

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      P 1 Reply Last reply
      0
      • S Swiss Mantoro

        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

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        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 )

        1 Reply Last reply
        0
        • D Dave Kreskowiak

          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

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Dave 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

          1 Reply Last reply
          0
          • S Swiss Mantoro

            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

            P Offline
            P Offline
            parth p
            wrote on last edited by
            #5

            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

            D S 2 Replies Last reply
            0
            • S Swiss Mantoro

              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

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • P parth p

                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

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                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

                P 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  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

                  P Offline
                  P Offline
                  parth p
                  wrote on last edited by
                  #8

                  Sorry, I didn't mean it.All i wanted to do was help him...

                  D 1 Reply Last reply
                  0
                  • P parth p

                    Sorry, I didn't mean it.All i wanted to do was help him...

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    • P parth p

                      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

                      S Offline
                      S Offline
                      Swiss Mantoro
                      wrote on last edited by
                      #10

                      Thank you for your attention and your direction to me, I will trying to use of your valuable inforamtion Thank you:-D

                      ICE

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups