By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

how can I use two txtbox to enter aphanumeric value and change it

P: 12
how can I use two txtbox to enter aphanumeric value and taking the first value of the textbox and placing it in the second txtbox with the numbers value being change to the actual wording (1,2 changes to one, two).
Nov 11 '06 #1
Share this Question
Share on Google+
18 Replies


100+
P: 1,646
how can I use two txtbox to enter aphanumeric value and taking the first value of the textbox and placing it in the second txtbox with the numbers value being change to the actual wording (1,2 changes to one, two).
Hi. What limits did you have in mind for these numbers?
For instance, do you want to have "one million five hundred thousand and forty two"
Nov 11 '06 #2

P: 12
Hi. What limits did you have in mind for these numbers?
For instance, do you want to have "one million five hundred thousand and forty two"
up to 10 is fine
Nov 11 '06 #3

P: 12
up to 10 is fine

can someone please help me I having such a hard time.
Nov 11 '06 #4

100+
P: 1,646
can someone please help me I having such a hard time.
You can do it this way using an array and the Split() function

This works though there are no checks on the user input
Expand|Select|Wrap|Line Numbers
  1.     Dim stAr(10) As String
  2.     Dim arInput As Variant
  3.     Dim stOutput As String
  4.     Dim intLoop As Integer
  5.  
  6.     stAr(0) = "zero"
  7.     stAr(1) = "one"
  8.     stAr(2) = "two"
  9.     stAr(3) = "three"
  10.     stAr(4) = "four"
  11.     stAr(5) = "five"
  12.     stAr(6) = "six"
  13.     stAr(7) = "seven"
  14.     stAr(8) = "eight"
  15.     stAr(9) = "nine"
  16.     stAr(10) = "ten"
  17.  
  18.     arInput = Split(Me.txtInput.Text, ",")
  19.     For intLoop = 0 To UBound(arInput) - 1
  20.         stOutput = stOutput & stAr(CInt(arInput(intLoop))) & ", "
  21.     Next intLoop
  22.     stOutput = stOutput & stAr(CInt(arInput(intLoop)))
  23.     Me.txtOutput.Text = stOutput
  24.  
Nov 11 '06 #5

P: 12
You can do it this way using an array and the Split() function

This works though there are no checks on the user input
Expand|Select|Wrap|Line Numbers
  1.     Dim stAr(10) As String
  2.     Dim arInput As Variant
  3.     Dim stOutput As String
  4.     Dim intLoop As Integer
  5.  
  6.     stAr(0) = "zero"
  7.     stAr(1) = "one"
  8.     stAr(2) = "two"
  9.     stAr(3) = "three"
  10.     stAr(4) = "four"
  11.     stAr(5) = "five"
  12.     stAr(6) = "six"
  13.     stAr(7) = "seven"
  14.     stAr(8) = "eight"
  15.     stAr(9) = "nine"
  16.     stAr(10) = "ten"
  17.  
  18.     arInput = Split(Me.txtInput.Text, ",")
  19.     For intLoop = 0 To UBound(arInput) - 1
  20.         stOutput = stOutput & stAr(CInt(arInput(intLoop))) & ", "
  21.     Next intLoop
  22.     stOutput = stOutput & stAr(CInt(arInput(intLoop)))
  23.     Me.txtOutput.Text = stOutput
  24.  
Thanks but can I actually use this with vb
I am actually trying to run it in VB 2005 express edition
Nov 11 '06 #6

P: 12
Thanks but can I actually use this with vb
I am actually trying to run it in VB 2005 express edition
I really appreciate your help

Thanks again
Nov 11 '06 #7

100+
P: 1,646
Thanks but can I actually use this with vb
I am actually trying to run it in VB 2005 express edition
I have no idea if this runs on .NET or not. Why not test it and see.
Put a couple of textboxes on a form with a button and paste this code into the button_click event. I tested the code with VB6

Let us know if it works.
Good luck
Nov 11 '06 #8

P: 12
I have no idea if this runs on .NET or not. Why not test it and see.
Put a couple of textboxes on a form with a button and paste this code into the button_click event. I tested the code with VB6

Let us know if it works.
Good luck
Thanks for your reply,

everything seems to be fine however, I get an error "variable 'stOutput' is used before it has been assigned a value. A null refference exception could result at runtime" and is this vb coding? I think it is.
Nov 13 '06 #9

100+
P: 1,646
Thanks for your reply,

everything seems to be fine however, I get an error "variable 'stOutput' is used before it has been assigned a value. A null refference exception could result at runtime" and is this vb coding? I think it is.
Try this just after the last Dim statement
stOutput = ""
Nov 13 '06 #10

P: 12
Try this just after the last Dim statement
stOutput = ""
Now I get A different error for this line stOutput = stOutput & stAr(CInt(arInput(intLoop)))

error: Conversion from string "jkhkjh" to type 'Integer' is not valid.

sorry about the stupid question. Yeah it is vb
Nov 13 '06 #11

P: 12
Try this just after the last Dim statement
stOutput = ""

Now I get a different error for this line stOutput = stOutput & stAr(CInt(arInput(intLoop)))

error: Conversion from string "juji67" to type 'Integer' is not valid.
Nov 13 '06 #12

P: 12
Now I get a different error for this line stOutput = stOutput & stAr(CInt(arInput(intLoop)))

error: Conversion from string "juji67" to type 'Integer' is not valid.
oh this is page two I was looking for the last post I thought it was on page 1
Nov 13 '06 #13

100+
P: 1,646
oh this is page two I was looking for the last post I thought it was on page 1
Did you copy and paste this code or did you type it in.
There is no error when run under vb6
What is being typed into the first textbox. this should be numbers separated by a comma.
Nov 13 '06 #14

100+
P: 1,646
Now I get A different error for this line stOutput = stOutput & stAr(CInt(arInput(intLoop)))

error: Conversion from string "jkhkjh" to type 'Integer' is not valid.

sorry about the stupid question. Yeah it is vb
This includes a check for numeric entries
Expand|Select|Wrap|Line Numbers
  1.     Dim stAr(10) As String
  2.     Dim arInput As Variant
  3.     Dim stOutput As String
  4.     Dim intLoop As Integer
  5.  
  6.     stOutput = ""
  7.  
  8.     stAr(0) = "zero"
  9.     stAr(1) = "one"
  10.     stAr(2) = "two"
  11.     stAr(3) = "three"
  12.     stAr(4) = "four"
  13.     stAr(5) = "five"
  14.     stAr(6) = "six"
  15.     stAr(7) = "seven"
  16.     stAr(8) = "eight"
  17.     stAr(9) = "nine"
  18.     stAr(10) = "ten"
  19.  
  20.     arInput = Split(Me.txtInput.Text, ",")
  21.     For intLoop = 0 To UBound(arInput) - 1
  22.         If IsNumeric(arInput(intLoop) Then
  23.             stOutput = stOutput & stAr(CInt(arInput(intLoop))) & ", "
  24.         Else
  25.             MsgBox "Please enter single numbers separated by a comma"
  26.             Me.txtInput.Text = ""
  27.             Me.txtInput.SetFocus
  28.             Exit Sub
  29.         End If
  30.     Next intLoop
  31.     stOutput = stOutput & stAr(CInt(arInput(intLoop)))
  32.     Me.txtOutput.Text = stOutput
  33.  
Nov 13 '06 #15

P: 12
This includes a check for numeric entries
Expand|Select|Wrap|Line Numbers
  1.     Dim stAr(10) As String
  2.     Dim arInput As Variant
  3.     Dim stOutput As String
  4.     Dim intLoop As Integer
  5.  
  6.     stOutput = ""
  7.  
  8.     stAr(0) = "zero"
  9.     stAr(1) = "one"
  10.     stAr(2) = "two"
  11.     stAr(3) = "three"
  12.     stAr(4) = "four"
  13.     stAr(5) = "five"
  14.     stAr(6) = "six"
  15.     stAr(7) = "seven"
  16.     stAr(8) = "eight"
  17.     stAr(9) = "nine"
  18.     stAr(10) = "ten"
  19.  
  20.     arInput = Split(Me.txtInput.Text, ",")
  21.     For intLoop = 0 To UBound(arInput) - 1
  22.         If IsNumeric(arInput(intLoop) Then
  23.             stOutput = stOutput & stAr(CInt(arInput(intLoop))) & ", "
  24.         Else
  25.             MsgBox "Please enter single numbers separated by a comma"
  26.             Me.txtInput.Text = ""
  27.             Me.txtInput.SetFocus
  28.             Exit Sub
  29.         End If
  30.     Next intLoop
  31.     stOutput = stOutput & stAr(CInt(arInput(intLoop)))
  32.     Me.txtOutput.Text = stOutput
  33.  
ok it does work however I was hoping to enter a words/letters and numbers without commans and convert the numbers from numeric to the actual world.

ex.

txtInput: hello123

click button

txtOutput: helloonetwothree

and if you don't mind can you then try and reverse it

txtInput: OneTwoThreehello
Nov 13 '06 #16

P: 12
ok it does work however I was hoping to enter a words/letters and numbers without commans and convert the numbers from numeric to the actual world.

ex.

txtInput: hello123

click button

txtOutput: helloonetwothree

and if you don't mind can you then try and reverse it

txtInput: OneTwoThreehello

sorry I mean txtOutput: OneTwoThreehello
Nov 13 '06 #17

100+
P: 1,646
ok it does work however I was hoping to enter a words/letters and numbers without commans and convert the numbers from numeric to the actual world.

ex.

txtInput: hello123

click button

txtOutput: helloonetwothree

and if you don't mind can you then try and reverse it

txtInput: OneTwoThreehello
Great so you now have a working model that you can improve upon and learn from. Happy hunting :)
Nov 13 '06 #18

P: 12
Great so you now have a working model that you can improve upon and learn from. Happy hunting :)
Thanks for all your help. I appriciated
Nov 13 '06 #19

Post your reply

Sign in to post your reply or Sign up for a free account.