working with textbox in visualbasic 6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dayalanstephen
    New Member
    • Jul 2006
    • 3

    working with textbox in visualbasic 6.0

    I have two textboxes, where i give input in one textbox and it reflects in another textbox. for eg., entering page numbers in the first textbox will be displayed as 1,2,3,4.... in the second textbox.Now if i want to delete a particular number how can i delete. Solution please
  • BSOB
    New Member
    • Jul 2006
    • 77

    #2
    tough... you gave the example 1,2,3,4... it is fairly easy if you know that the string will be EXACTLY that format. im going to assume that, just so i can give a fairly easy solution.

    i assume you ALREADY have something like this:
    text1_change()
    text2.text=text 1.text
    end sub

    if we know that the "page numbers" are always going to be one digit numbers (like your example) then we can do this:
    text1_change()
    dim i as integer
    const BadChr = "4" ' the page number you DONT want.
    for i = 1 to len(text1.text) 'looks at each character individually
    if mid(text1.text, i,1) <> badchr then text2.text = text2.text & mid(text1.text, i,1)
    next i
    end sub

    input: "1,2,3,4,5, 6,7"
    output: "1,2,3,,5,6 ,7"

    if you want to remove that extra comma, or have more than 1 digit numbers, or if the input could be a different format, i wish you would explain that in your question. but until people learn to explain there questions, i will answer them as they are written.
    -bsob

    Comment

    • dayalanstephen
      New Member
      • Jul 2006
      • 3

      #3
      Thanks for your reply BSOB,
      the input will be either 1 digit or 2 or 3 or more digit, which will in turn reflect in the second textbox, If i want to delete a particular number along with the comma by getting an input through a inputbox how should i write the program. Solution please.

      Comment

      • steve young
        New Member
        • Jul 2006
        • 6

        #4
        Hi I'm afraid I don't know your solution, but I wonder, could I be cheeky? I am trying to write a program that has 17 text boxes on it, each being hidden until the appropriate button is pressed. I would like to be able to have input from the box I am using (i.e. January, Febuary, etc, put into another (hidden) text box automatically, similar, I think, to what you are doing. Is it possible to share some code? I am a complete beginner though.

        Comment

        • BSOB
          New Member
          • Jul 2006
          • 77

          #5
          steve, start your own thread AND please be more specific.

          dayalanstephen,
          thank you for being more specific.

          dim Unwanted as string 'in general declarations for big scope
          private sub ChangeUnwantedB tn_click() 'a button to change the unwanted number
          Unwanted = inputbox("what number dont you want?")
          end sub
          private sub text1_change()
          Dim CurrentNum as string 'the current number itis reading
          Dim CurrentPosition as integer 'the position in the string that it is reading
          do until currentposition = len(text1.text) +1
          currentposition = currentposition + 1
          if mid(text1.text, currentposition ,1) = "," then
          if val(currentnum) <> val(unwanted) then text2.text=text 2.text & val(currentnum) & ", "
          currentnum = ""
          else
          currentnum = currentnum & mid(text1.text, currentposition ,1)
          end if
          loop
          if val(currentnum) <> val(unwanted) then text2.text=text 2.text & val(currentnum)
          end sub


          i think that will do it for you. could be typos and code has not been tested. on the "do" line, im not sure if you want the "+1" on the end or not, you will have to test that.
          -bsob

          Comment

          • dayalanstephen
            New Member
            • Jul 2006
            • 3

            #6
            thanks for the reply bsob,
            i tried with the codings which you gave, but it does not reflect the textbox2.
            Also i want to know why you use text1.text coz i use an inputbox and that should directly reflect textbox2 where you have the numbers like 2,4,8,12,35,99, 105 in textbox2. Through an inputbox i select the number that is unwanted as the same code which you have used
            private sub ChangeUnwantedB tn_click() 'a button to change the unwanted number
            Unwanted = inputbox("what number dont you want?")
            end sub
            but please tell me why you use text1_change( ) and please help me out line by line with comments what that particular line does. Please BSOB......

            Comment

            • BSOB
              New Member
              • Jul 2006
              • 77

              #7
              I assumed that your application would have one number you didnt want, and you would be putting in lots of data (into text1) without changing your unwanted number. That would allow you to type into text1 the text that you have and any time that you type, it will post that text (from text1 to text2) without the undesired number.

              text1_change() will update text2 as often as you type anything into text1. that is why i used it.

              from reading your question, i gather that your raw data is input into text1 and then you want the editted data (without undesired number) to appear in text2. is that correct?
              ill do line by line help when i feel like i fully understand your question. use examples, use "what ifs" and try to give me as clear an idea as possible, thanks.
              -sorry for being away for a few days.

              Comment

              Working...