Results 1 to 8 of 8

Thread: number in to text

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158

    number in to text

    I want to convert a number in to text. I dont know a built in function for this.

    100 should be

    One Hundred

    1001

    One Thousend and one

    thanks in advance
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. CStr(1001)
    2.  
    3. 'Or just
    4.  
    5. 1001 & ""

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    No, he wants text, as in spoken word.

    Perhaps this is of help?
    http://pub13.ezboard.com/fvisualbasi...opicID=1.topic
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    D'oh.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    it doesn't convert the number in to text
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  6. #6
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    yes it does, it does it perfectly. all you have to do is copy and paste it, or just this:

    VB Code:
    1. Private Sub Command1_Click()
    2.     'first set up two arrays to convert numbers to words
    3.     Dim BigOnes(9) As String
    4.     Dim SmallOnes(19) As String
    5.     'and populate them
    6.     BigOnes(1) = "Ten"
    7.     BigOnes(2) = "Twenty"
    8.     BigOnes(3) = "Thirty"
    9.     BigOnes(4) = "Forty"
    10.     BigOnes(5) = "Fifty"
    11.     BigOnes(6) = "Sixty"
    12.     BigOnes(7) = "Seventy"
    13.     BigOnes(8) = "Eighty"
    14.     BigOnes(9) = "Ninety"
    15.     SmallOnes(1) = "One"
    16.     SmallOnes(2) = "Two"
    17.     SmallOnes(3) = "Three"
    18.     SmallOnes(4) = "Four"
    19.     SmallOnes(5) = "Five"
    20.     SmallOnes(6) = "Six"
    21.     SmallOnes(7) = "Seven"
    22.     SmallOnes(8) = "Eight"
    23.     SmallOnes(9) = "Nine"
    24.     SmallOnes(10) = "Ten"
    25.     SmallOnes(11) = "Eleven"
    26.     SmallOnes(12) = "Twelve"
    27.     SmallOnes(13) = "Thirteen"
    28.     SmallOnes(14) = "Fourteen"
    29.     SmallOnes(15) = "Fifteen"
    30.     SmallOnes(16) = "Sixteen"
    31.     SmallOnes(17) = "Seventeen"
    32.     SmallOnes(18) = "Eighteen"
    33.     SmallOnes(19) = "Nineteen"
    34.     'format the incoming number to guarantee six digits
    35.     'to the left of the decimal point and two to the right
    36.     'and then separate the dollars from the cents
    37.     Text1.Text = Format(Text1.Text, "000000.00")
    38.     Dollars = Left(Text1.Text, 6)
    39.     Cents = Right(Text1.Text, 2)
    40.     Words = ""
    41.     'check to make sure incoming number is not too large
    42.     If Dollars > 999999 Then
    43.         Text2.Text = "Dollar amount is too large"
    44.         Exit Sub
    45.     End If
    46.     'separate the dollars into chunks
    47.     If Dollars = 0 Then
    48.         Words = "Zero"
    49.     Else
    50.         'first do the thousands
    51.         Chunk = Left(Dollars, 3)
    52.         If Chunk > 0 Then
    53.             GoSub ParseChunk
    54.             Words = Words & " Thousand"
    55.         End If
    56.         'do the rest of the dollars
    57.         Chunk = Right(Dollars, 3)
    58.         If Chunk > 0 Then
    59.             GoSub ParseChunk
    60.         End If
    61.     End If
    62.     'concatenate the cents and display
    63.     If Cents = 0 Then Cents = "No"
    64.     Words = Words & " and " & Cents & "/100"
    65.     Text2.Text = Words
    66.     Exit Sub
    67.    
    68. ParseChunk:      digits = Mid(Chunk, 1, 1)
    69.     If digits > 0 Then
    70.         Words = Words & " " & SmallOnes(digits) & " Hundred"
    71.     End If
    72.     digits = Mid(Chunk, 2, 2)
    73.     If digits > 19 Then
    74.         leftdigit = Mid(Chunk, 2, 1)
    75.         rightdigit = Mid(Chunk, 3, 1)
    76.         Words = Words & " " & BigOnes(leftdigit)
    77.         If rightdigit > 0 Then
    78.             Words = Words & " " & SmallOnes(rightdigit)
    79.         End If
    80.     Else
    81.         If digits > 0 Then
    82.             Words = Words & " " & SmallOnes(digits)
    83.         End If
    84.     End If
    85.     Return
    86. End Sub

    basically, 2 textboxes (text1,text2) and a command button (command1). enter your number into the text1, and then press the button. then the result will appear in text2.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  7. #7
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    yeah the second code works

    Cstr doesn't work . any way thanks guys.

    I solved the problem
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

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