943,028 Members | Top Members by Rank

Ad:
Mar 19th, 2010
0

converting number to words

Expand Post »
hello!
is there any body to help me.
i want to know the codes of converting number to words...
pls help me to do it.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
quicka_29 is offline Offline
1 posts
since Mar 2010
Mar 19th, 2010
0
Re: converting number to words
You need to convert 10 to "10"?
Or you want to convert 65 to "A"?

First case, use "C" functions - CStr, CInt, CLng, CBool... -, to convert any type to the type specified in function name. This cNum = CStr(nValor) puts the integer value of nValor variable in the cNum string variable, in format of a string.

Second case, use CHR (to convert from number to letter) or ASC (to convert from letter to number) functions, both uses ASCII table for converting.


Please, be more specific when you ask for help; if possible, uses examples.


Sidnei
Reputation Points: 22
Solved Threads: 10
Junior Poster in Training
sidnei is offline Offline
55 posts
since Dec 2009
Mar 20th, 2010
0
Re: converting number to words
sidnei, I believe quick is wanting to convert 1,234.56 to One thousand two hundred thirty four and fifty six or ... four dollars and fifty six cents...

So quick, I suggest you use your friends (yahoo, google, ask, answers, bing) and search for vb6 convert number to words or if I remember correctly, search this forum for those keywords as I believe just a month or so ago someone posted the solution you are looking for...



Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Mar 20th, 2010
-1
Re: converting number to words
if you convert 10 to 'ten' then try this
No declarations at all.
1. Create a form and add two textboxes; TextBox1 and TextBox2
2. Add a command button; CommandButton1
3. Copy the code below to the code window.
4. Run the program, enter the number in TextBox1 and click CommandButton1...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Function Getword(strNumber)
  3. Dim strtemp As String
  4. Dim x, y, z As Integer
  5. x = Val(Mid$(strNumber, 1, 1))
  6. y = Val(Mid$(strNumber, 2, 1))
  7. z = Val(Mid$(strNumber, 3, 1))
  8.  
  9. If Len(strNumber) = 1 Then
  10. strtemp = strtemp + Whole(Val(strNumber))
  11. GoTo 20
  12. ElseIf Len(strNumber) = 2 Then
  13. If x = 1 And y = 0 Then
  14. strtemp = strtemp + " Ten"
  15. ElseIf x = 1 And y = 1 Then
  16. strtemp = strtemp + " Eleven"
  17. GoTo 20
  18. ElseIf x = 1 And y = 2 Then
  19. strtemp = strtemp + " Twelve"
  20. GoTo 20
  21. ElseIf x = 1 And y > 2 Then
  22. strtemp = strtemp + Whole2(y) + "een"
  23. GoTo 20
  24. ElseIf x = 0 And y > 0 Then
  25. strtemp = strtemp + Whole(y)
  26. GoTo 20
  27. ElseIf x = 0 And y = 0 Then
  28. strtemp = ""
  29. GoTo 20
  30. Else
  31. strtemp = Whole2(x) + "y"
  32. If y > 0 Then strtemp = strtemp + Whole(y)
  33. GoTo 20
  34. End If
  35.  
  36. ElseIf Len(strNumber) = 3 Then
  37.  
  38. If x > 0 Then strtemp = strtemp + Whole(x) + " Hundred"
  39. If y = 1 And z > 2 Then
  40. strtemp = strtemp + Whole2(z) + "een"
  41. GoTo 20
  42. ElseIf y = 1 And z = 1 Then
  43. strtemp = strtemp + " Eleven"
  44. GoTo 20
  45. ElseIf y = 1 And z = 2 Then
  46. strtemp = strtemp + " Twelve"
  47. GoTo 20
  48. ElseIf y = 1 And z = 0 Then
  49. strtemp = strtemp + " Ten"
  50. GoTo 20
  51. ElseIf x = 0 And y = 0 And z = 0 Then
  52. strtemp = ""
  53. GoTo 20
  54. Else
  55. End If
  56. If y > 0 Then strtemp = strtemp + Whole2(y) + "y"
  57. If z > 0 Then strtemp = strtemp + Whole(z)
  58. End If
  59. 20 Getword = strtemp
  60.  
  61. End Function
  62.  
  63. Function Whole(ByVal x As Integer)
  64. Select Case x
  65. Case Is = 9
  66. Whole = " Nine"
  67. Case 8
  68. Whole = " Eight"
  69. Case 7
  70. Whole = " Seven"
  71. Case 6
  72. Whole = " Six"
  73. Case 5
  74. Whole = " Five"
  75. Case 4
  76. Whole = " Four"
  77. Case 3
  78. Whole = " Three"
  79. Case 2
  80. Whole = " Two"
  81. Case 1
  82. Whole = " One"
  83. End Select
  84. End Function
  85.  
  86. Function Whole2(ByVal x As Integer)
  87. Select Case x
  88. Case Is = 9
  89. Whole2 = " Ninet"
  90. Case 8
  91. Whole2 = " Eight"
  92. Case 7
  93. Whole2 = " Sevent"
  94. Case 6
  95. Whole2 = " Sixt"
  96. Case 5
  97. Whole2 = " Fift"
  98. Case 4
  99. Whole2 = " Fourt"
  100. Case 3
  101. Whole2 = " Thirt"
  102. Case 2
  103. Whole2 = " Twent"
  104. End Select
  105. End Function
  106.  
  107. Private Sub CommandButton1_Click()
  108. Dim bigstrNumber(11)
  109. Dim strAdd As String
  110. Dim strNumber As String
  111. Dim strtemp As String
  112. TextBox1 = Abs(Int(TextBox1))
  113. strNumber = TextBox1.Text
  114. TextBox2 = ""
  115. bigstrNumber(0) = ""
  116. bigstrNumber(1) = " Thousand"
  117. bigstrNumber(2) = " Million"
  118. bigstrNumber(3) = " Billion"
  119. bigstrNumber(4) = " Trillion"
  120. bigstrNumber(5) = " Quadrillion"
  121. bigstrNumber(6) = " Pentillion"
  122. bigstrNumber(7) = " Hexillion"
  123. bigstrNumber(8) = " Qentillion"
  124. bigstrNumber(9) = " Octillion"
  125. bigstrNumber(10) = " Nonillion"
  126. bigstrNumber(11) = " Decillion"
  127.  
  128. If Len(strNumber) > 3 Then
  129. Do While i < 36
  130. m = m + 1
  131. i = i + 3
  132. If i >= Len(strNumber) Then Exit Do
  133. Loop
  134. c = i - Len(strNumber)
  135. If c > 0 Then
  136. For D = 1 To c
  137. strAdd = strAdd + "0"
  138. Next D
  139. Else
  140. End If
  141. strNumber = strAdd + strNumber
  142. k = 1
  143. For i = 1 To m
  144. TextBox2 = TextBox2 & Getword(Mid$(strNumber, k, 3))
  145. If Mid$(strNumber, k, 3) <> "000" Then TextBox2 = TextBox2 & bigstrNumber(m - i)
  146. k = k + 3
  147. Next i
  148. Else
  149. End If
  150. TextBox2 = Trim$(TextBox2 & Getword(strNumber))
  151. TextBox1 = Format$(TextBox1, "###,###,###,###,###,###,###,###,###,###,###,###")
  152. End Sub
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Mar 20th, 2010
0
Re: converting number to words
Click to Expand / Collapse  Quote originally posted by abu taher ...
if you convert 10 to 'ten' then try this
No declarations at all.
1. Create a form and add two textboxes; TextBox1 and TextBox2
2. Add a command button; CommandButton1
3. Copy the code below to the code window.
4. Run the program, enter the number in TextBox1 and click CommandButton1..
What are they going to learn turning in your program? And don't tell me "they use it for a pattern for their own code" -- you know that doesn't happen much. And even so, we help people write their own code, we don't give handouts. Handouts they can get from Google.

After 600+ posts you should know all this.
Moderator
Reputation Points: 3275
Solved Threads: 885
Posting Sage
WaltP is offline Offline
7,695 posts
since May 2006
Mar 28th, 2010
0
Re: converting number to words
Click to Expand / Collapse  Quote originally posted by WaltP ...
What are they going to learn turning in your program? And don't tell me "they use it for a pattern for their own code" -- you know that doesn't happen much. And even so, we help people write their own code, we don't give handouts. Handouts they can get from Google.

After 600+ posts you should know all this.
I only try this. but I don't know................what I did for my reputation. thanks.
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Mar 31st, 2010
0

Numbers to words

hi ive got the same problem i tried the codes u gave but when i run the prog i get no response

where exactly do i code coz i coded in command1


thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Masterace is offline Offline
17 posts
since Oct 2009
Mar 31st, 2010
0
Re: converting number to words
properly change the textbox and button name as I said. look clearly.
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Apr 6th, 2010
0
Re: converting number to words
Click to Expand / Collapse  Quote originally posted by quicka_29 ...
hello!
is there any body to help me.
i want to know the codes of converting number to words...
pls help me to do it.
Dibyendu Goswami ( email snipped)
I send you this link . I think your Problem will be solved
link snipped
Last edited by WaltP; Apr 6th, 2010 at 6:23 pm. Reason: Do not post email addresses on forums, Keep answers on this site as per The Rules
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dreemebird is offline Offline
3 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: How to make Database of Super market in vb and connect to access
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: about .mhf file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC