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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cipher2079
    New Member
    • Jul 2006
    • 12

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

    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).
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by cipher2079
    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"

    Comment

    • cipher2079
      New Member
      • Jul 2006
      • 12

      #3
      Originally posted by willakawill
      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

      Comment

      • cipher2079
        New Member
        • Jul 2006
        • 12

        #4
        Originally posted by cipher2079
        up to 10 is fine

        can someone please help me I having such a hard time.

        Comment

        • willakawill
          Top Contributor
          • Oct 2006
          • 1646

          #5
          Originally posted by cipher2079
          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
          Code:
              Dim stAr(10) As String
              Dim arInput As Variant
              Dim stOutput As String
              Dim intLoop As Integer
              
              stAr(0) = "zero"
              stAr(1) = "one"
              stAr(2) = "two"
              stAr(3) = "three"
              stAr(4) = "four"
              stAr(5) = "five"
              stAr(6) = "six"
              stAr(7) = "seven"
              stAr(8) = "eight"
              stAr(9) = "nine"
              stAr(10) = "ten"
              
              arInput = Split(Me.txtInput.Text, ",")
              For intLoop = 0 To UBound(arInput) - 1
                  stOutput = stOutput & stAr(CInt(arInput(intLoop))) & ", "
              Next intLoop
              stOutput = stOutput & stAr(CInt(arInput(intLoop)))
              Me.txtOutput.Text = stOutput

          Comment

          • cipher2079
            New Member
            • Jul 2006
            • 12

            #6
            Originally posted by willakawill
            You can do it this way using an array and the Split() function

            This works though there are no checks on the user input
            Code:
                Dim stAr(10) As String
                Dim arInput As Variant
                Dim stOutput As String
                Dim intLoop As Integer
                
                stAr(0) = "zero"
                stAr(1) = "one"
                stAr(2) = "two"
                stAr(3) = "three"
                stAr(4) = "four"
                stAr(5) = "five"
                stAr(6) = "six"
                stAr(7) = "seven"
                stAr(8) = "eight"
                stAr(9) = "nine"
                stAr(10) = "ten"
                
                arInput = Split(Me.txtInput.Text, ",")
                For intLoop = 0 To UBound(arInput) - 1
                    stOutput = stOutput & stAr(CInt(arInput(intLoop))) & ", "
                Next intLoop
                stOutput = stOutput & stAr(CInt(arInput(intLoop)))
                Me.txtOutput.Text = stOutput
            Thanks but can I actually use this with vb
            I am actually trying to run it in VB 2005 express edition

            Comment

            • cipher2079
              New Member
              • Jul 2006
              • 12

              #7
              Originally posted by cipher2079
              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

              Comment

              • willakawill
                Top Contributor
                • Oct 2006
                • 1646

                #8
                Originally posted by cipher2079
                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

                Comment

                • cipher2079
                  New Member
                  • Jul 2006
                  • 12

                  #9
                  Originally posted by willakawill
                  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.

                  Comment

                  • willakawill
                    Top Contributor
                    • Oct 2006
                    • 1646

                    #10
                    Originally posted by cipher2079
                    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 = ""

                    Comment

                    • cipher2079
                      New Member
                      • Jul 2006
                      • 12

                      #11
                      Originally posted by willakawill
                      Try this just after the last Dim statement
                      stOutput = ""
                      Now I get A different error for this line stOutput = stOutput & stAr(CInt(arInp ut(intLoop)))

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

                      sorry about the stupid question. Yeah it is vb

                      Comment

                      • cipher2079
                        New Member
                        • Jul 2006
                        • 12

                        #12
                        Originally posted by willakawill
                        Try this just after the last Dim statement
                        stOutput = ""

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

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

                        Comment

                        • cipher2079
                          New Member
                          • Jul 2006
                          • 12

                          #13
                          Originally posted by cipher2079
                          Now I get a different error for this line stOutput = stOutput & stAr(CInt(arInp ut(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

                          Comment

                          • willakawill
                            Top Contributor
                            • Oct 2006
                            • 1646

                            #14
                            Originally posted by cipher2079
                            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.

                            Comment

                            • willakawill
                              Top Contributor
                              • Oct 2006
                              • 1646

                              #15
                              Originally posted by cipher2079
                              Now I get A different error for this line stOutput = stOutput & stAr(CInt(arInp ut(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
                              Code:
                                  Dim stAr(10) As String
                                  Dim arInput As Variant
                                  Dim stOutput As String
                                  Dim intLoop As Integer
                                  
                                  stOutput = ""
                              
                                  stAr(0) = "zero"
                                  stAr(1) = "one"
                                  stAr(2) = "two"
                                  stAr(3) = "three"
                                  stAr(4) = "four"
                                  stAr(5) = "five"
                                  stAr(6) = "six"
                                  stAr(7) = "seven"
                                  stAr(8) = "eight"
                                  stAr(9) = "nine"
                                  stAr(10) = "ten"
                                  
                                  arInput = Split(Me.txtInput.Text, ",")
                                  For intLoop = 0 To UBound(arInput) - 1
                                      If IsNumeric(arInput(intLoop) Then
                                          stOutput = stOutput & stAr(CInt(arInput(intLoop))) & ", "
                                      Else
                                          MsgBox "Please enter single numbers separated by a comma"
                                          Me.txtInput.Text = ""
                                          Me.txtInput.SetFocus
                                          Exit Sub
                                      End If
                                  Next intLoop
                                  stOutput = stOutput & stAr(CInt(arInput(intLoop)))
                                  Me.txtOutput.Text = stOutput

                              Comment

                              Working...