Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

i need it very soooooon

Posted on 2000-03-19
3
Medium Priority
?
156 Views
Last Modified: 2010-05-02
Hi experts
how can i change the contents of an textbox which are numaric to an letters in another textbox like:
textbox 1 : 102
textbox 2 : one handerd and two
0
Comment
Question by:loay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:lgadi
ID: 2633279
Hi
  Well, there's no really easy way I know, except writing a (quite simple) function that gets a number and return its representation in words, by means of divisions and remainders.
 
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2633289
"Converting Numbers to Words"

http://www.vb-world.net/misc/tip108.html
0
 
LVL 9

Accepted Solution

by:
Dalin earned 150 total points
ID: 2633313
Try this:

1, add the foolowing functions:
  Function ConvertNumberToWord(ByVal vLgNumber) As String
 
 Dim lTemp As String
 Dim lTheNumber As String
 Dim lMyWord As String
 Dim place(9) As String
 Dim Count As Integer
 
 place(2) = " Thousand "
 place(3) = " Million "
 place(4) = " Billion "
 place(5) = " Trillion "

lTheNumber = Trim(Str(vLgNumber))
        Count = 1
        Do While lTheNumber <> ""
                ' Convert last 3 digits of lTheNumber to English word
                lTemp = ConvertHundreds(Right(lTheNumber, 3))
                If lTemp <> "" Then lMyWord = lTemp & place(Count) & lMyWord
                If Len(lTheNumber) > 3 Then
                        ' Remove last 3 converted digits from it
                        lTheNumber = Left(lTheNumber, Len(lTheNumber) - 3)
                    Else
                        lTheNumber = ""
                    End If
                Count = Count + 1
            Loop
   

ConvertNumberToWord = lMyWord
End Function
 Private Function ConvertDigit(ByVal MyDigit) As String
        Select Case Val(MyDigit)
             Case 1: ConvertDigit = "One"
             Case 2: ConvertDigit = "Two"
             Case 3: ConvertDigit = "Three"
             Case 4: ConvertDigit = "Four"
             Case 5: ConvertDigit = "Five"
             Case 6: ConvertDigit = "Six"
             Case 7: ConvertDigit = "Seven"
             Case 8: ConvertDigit = "Eight"
             Case 9: ConvertDigit = "Nine"
             Case Else: ConvertDigit = ""
          End Select
 End Function
 Private Function ConvertHundreds(ByVal vLgNumber)
            Dim Result As String
            ' Exit if there is nothing to convert.
            If Val(vLgNumber) = 0 Then Exit Function
            ' Append leading zeros to number.
                    vLgNumber = Right("000" & vLgNumber, 3)
                    ' Do we have a hundreds place digit to c
                    '     onvert?
                    If Left(vLgNumber, 1) <> "0" Then
                              Result = ConvertDigit(Left(vLgNumber, 1)) & " Hundred "
                          End If
                          ' Do we have a tens place digit to conve
                          '     rt?
                          If Mid(vLgNumber, 2, 1) <> "0" Then
                              Result = Result & ConvertTens(Mid(vLgNumber, 2))
                             
                          Else
                              ' If not, then convert the ones place di
                              '     git.
                              Result = Result & ConvertDigit(Mid(vLgNumber, 3))
                          End If
                          ConvertHundreds = Trim(Result)
                      End Function
 Private Function ConvertTens(ByVal MyTens)
                          Dim Result As String
                          ' Is value between 10 and 19?
                          If Val(Left(MyTens, 1)) = 1 Then
                              Select Case Val(MyTens)
                                  Case 10: Result = "Ten"
                                  Case 11: Result = "Eleven"
                                  Case 12: Result = "Twelve"
                                  Case 13: Result = "Thirteen"
                                  Case 14: Result = "Fourteen"
                                  Case 15: Result = "Fifteen"
                                  Case 16: Result = "Sixteen"
                                  Case 17: Result = "Seventeen"
                                  Case 18: Result = "Eighteen"
                                  Case 19: Result = "Nineteen"
                                  Case Else
                              End Select
                      Else
                          ' .. otherwise it's between 20 and 99.


                          Select Case Val(Left(MyTens, 1))
                              Case 2: Result = "Twenty "
                              Case 3: Result = "Thirty "
                              Case 4: Result = "Forty "
                              Case 5: Result = "Fifty "
                              Case 6: Result = "Sixty "
                              Case 7: Result = "Seventy "
                              Case 8: Result = "Eighty "
                              Case 9: Result = "Ninety "
                              Case Else
                          End Select
                      ' Convert ones place digit.
                      Result = Result & ConvertDigit(Right(MyTens, 1))
                      End If
                      ConvertTens = Result
                      End Function

2. to covert the number in text1 and display in Text 2

Text2.Text = ConvertNumberToWord(CLng(Text1.Text))
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question