Results 1 to 5 of 5

Thread: Number to word

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Cool

    I did a search on vb-world for a NUMBER TO WORD function and found two... but gess what.... they don't work because I have a decimal point. (this is for currency)

    Is there anyone out there that has such a function?

    [Edited by David Laplante on 06-29-2000 at 11:20 AM]

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    So what exactly are you after?

    £100.00 = One Hundred

    £101.12 = One Hundred and One point Twelve
    Iain, thats with an i by the way!

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    you need to conver a number to a string? or what do you mean?

    use cstr to convert a variable to string
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    Why not call the NUMBER->WORD function twice, once with the number in front of the decimal point, and then again with the number after the decimal point;

    eg;

    Code:
    Dim MyNumber as Double
    Dim TempString As String
    Dim ResultString As String
    Dim FindPoint As Integer
    
    ResultString=""
    TempString=Cstr(MyNumber)
    FindPoint=Instr(TempString,".")
    If FindPoint=0 Then
      ResultString=NumberToWords(Cint(MyNumber))
    Else
      ResultString=NumberToWords(CInt(Left(TempString,FindPoint-1)))
      ResultString=ResultString+" point "
      ResultString=ResultString+NumberToWords(Cint(Right(TempString,Len(TempString)-FindPoint))
    End If
    If the NumberToWords function you are using doesn't accept Integers, change the CINTs to the appropriate conversion function (eg Clng - LONG, Cdbl - DOUBLE etc)






    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  5. #5
    New Member
    Join Date
    Jun 2000
    Location
    DC area
    Posts
    2
    http://www.mvps.org/vbnet/code/helpers/numbertotext.htm

    I found the aforementioned site yesterday. I believe that is a very thorough NUMBER to WORD routine. It includes the ability to convert monetary and decimal values into their "verbal" format. i.e. $1.30 as in One Dollar and Thirty Cents.

    Good Luck
    Tom

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