|
-
Nov 11th, 2002, 12:19 AM
#1
Thread Starter
Addicted Member
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
-
Nov 11th, 2002, 12:20 AM
#2
VB Code:
CStr(1001)
'Or just
1001 & ""
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Nov 11th, 2002, 12:21 AM
#3
Good Ol' Platypus
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)
-
Nov 11th, 2002, 12:24 AM
#4
D'oh.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Nov 11th, 2002, 12:27 AM
#5
Thread Starter
Addicted Member
it doesn't convert the number in to text
-
Nov 11th, 2002, 12:57 AM
#6
The picture isn't missing
yes it does, it does it perfectly. all you have to do is copy and paste it, or just this:
VB Code:
Private Sub Command1_Click()
'first set up two arrays to convert numbers to words
Dim BigOnes(9) As String
Dim SmallOnes(19) As String
'and populate them
BigOnes(1) = "Ten"
BigOnes(2) = "Twenty"
BigOnes(3) = "Thirty"
BigOnes(4) = "Forty"
BigOnes(5) = "Fifty"
BigOnes(6) = "Sixty"
BigOnes(7) = "Seventy"
BigOnes(8) = "Eighty"
BigOnes(9) = "Ninety"
SmallOnes(1) = "One"
SmallOnes(2) = "Two"
SmallOnes(3) = "Three"
SmallOnes(4) = "Four"
SmallOnes(5) = "Five"
SmallOnes(6) = "Six"
SmallOnes(7) = "Seven"
SmallOnes(8) = "Eight"
SmallOnes(9) = "Nine"
SmallOnes(10) = "Ten"
SmallOnes(11) = "Eleven"
SmallOnes(12) = "Twelve"
SmallOnes(13) = "Thirteen"
SmallOnes(14) = "Fourteen"
SmallOnes(15) = "Fifteen"
SmallOnes(16) = "Sixteen"
SmallOnes(17) = "Seventeen"
SmallOnes(18) = "Eighteen"
SmallOnes(19) = "Nineteen"
'format the incoming number to guarantee six digits
'to the left of the decimal point and two to the right
'and then separate the dollars from the cents
Text1.Text = Format(Text1.Text, "000000.00")
Dollars = Left(Text1.Text, 6)
Cents = Right(Text1.Text, 2)
Words = ""
'check to make sure incoming number is not too large
If Dollars > 999999 Then
Text2.Text = "Dollar amount is too large"
Exit Sub
End If
'separate the dollars into chunks
If Dollars = 0 Then
Words = "Zero"
Else
'first do the thousands
Chunk = Left(Dollars, 3)
If Chunk > 0 Then
GoSub ParseChunk
Words = Words & " Thousand"
End If
'do the rest of the dollars
Chunk = Right(Dollars, 3)
If Chunk > 0 Then
GoSub ParseChunk
End If
End If
'concatenate the cents and display
If Cents = 0 Then Cents = "No"
Words = Words & " and " & Cents & "/100"
Text2.Text = Words
Exit Sub
ParseChunk: digits = Mid(Chunk, 1, 1)
If digits > 0 Then
Words = Words & " " & SmallOnes(digits) & " Hundred"
End If
digits = Mid(Chunk, 2, 2)
If digits > 19 Then
leftdigit = Mid(Chunk, 2, 1)
rightdigit = Mid(Chunk, 3, 1)
Words = Words & " " & BigOnes(leftdigit)
If rightdigit > 0 Then
Words = Words & " " & SmallOnes(rightdigit)
End If
Else
If digits > 0 Then
Words = Words & " " & SmallOnes(digits)
End If
End If
Return
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  .
-
Nov 11th, 2002, 01:02 AM
#7
Frenzied Member
-
Nov 11th, 2002, 01:06 AM
#8
Thread Starter
Addicted Member
yeah the second code works
Cstr doesn't work . any way thanks guys.
I solved the problem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|