Results 1 to 8 of 8

Thread: One Hundred Dollars

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    One Hundred Dollars

    A class to convert a decimal variable into its spoken word equivalent string...

    123.45 converts to "ONE HUNDRED AND TWENTY THREE DOLLARS, FORTY FIVE CENTS". It could be modified to remove the dollars and cents strings.

    It can convert numbers in the range 0 to 1.0E+25 inclusive, so no negative numbers please.

    Call it like this...

    VB Code:
    1. MessageBox.Show(CashToWords.WriteNumberInWords(Decimal.Parse("123.45")))

    Its a shared method so there's no need to create an instance of the class first.

    Enjoy
    Attached Files Attached Files
    I don't live here any more.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: One Hundred Dollars

    If you want it in Check format, you would have "ONE HUNDRED AND TWENTY THREE DOLLARS + 45/100", as the cents usually aren't spelled out. I may try to change it on my own

    Nice job.

  3. #3

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: One Hundred Dollars

    Go for it. The post that inspired this wanted the cents in words I think, unless my memory has packed up.

  4. #4
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: One Hundred Dollars

    Thanks Wossname, I have used this here in the UK by simply ammending the line.
    VB Code:
    1. buf.Append("POUNDS, " & cents & " PENCE")

  5. #5
    Addicted Member
    Join Date
    Jan 2007
    Posts
    220

    Re: One Hundred Dollars

    when i copied and pasted it its givin an error as "StringBuilder" is not defined?

  6. #6
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: One Hundred Dollars

    You have to Import the NameSpace
    Code:
    System.Text.StringBuilder
    Please mark you thread resolved using the Thread Tools as shown

  7. #7
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: One Hundred Dollars

    I should probably point out that technically it produces the wrong results:

    $123.45 = "One Hundred Twenty Three Dollars and Forty Five Cents"

    Whereas:
    "ONE HUNDRED AND TWENTY THREE DOLLARS, FORTY FIVE CENTS" = "100.$23, $0.45" which isn't a dollar amount at all.
    Last edited by JuggaloBrotha; Jun 30th, 2010 at 03:00 PM.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  8. #8
    Addicted Member vb_ftw's Avatar
    Join Date
    Dec 2010
    Posts
    139

    Re: One Hundred Dollars

    thanks...i was looking for this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width