locked
Read line to line in an array from an textbox RRS feed

  • Question

  • Hello

    I have a textbox with many things on each line one thing i give an example

    http://svekke.sin.khk.be/accijns.JPG

    I need line
    1,2,3,5
    8,9,10,12
    ........

    line 1 and 8 are the same --> must be in an array
    2 and 9 are the same --> must be in a different array
    3 and 10 are the same --> must be in a different array
    5 and 12 are the same --> must be in a different array

    I hope you can help me?
    To do this ??

    Saturday, April 29, 2006 12:48 PM

All replies

  • You could create an array of arrays. Then read the first line from the textbox, create a new array in your array of arrays and assign it as the first value. Then read in the second line, compare it against the first value of the first array. If they're the same, then add the second line to this array, if not, create a new array and add it to this one. Continue until the end of the textbox is reached.

    Saturday, April 29, 2006 2:06 PM
  •  Pierce Blaylock wrote:

    You could create an array of arrays. Then read the first line from the textbox, create a new array in your array of arrays and assign it as the first value. Then read in the second line, compare it against the first value of the first array. If they're the same, then add the second line to this array, if not, create a new array and add it to this one. Continue until the end of the textbox is reached.



    There is nothing the same
    How could i compare them then ??
    Saturday, April 29, 2006 4:19 PM
  • Yes there is. The lines themselves. As you said, some lines are the same such as lines 1 and 8. You compare the actual lines with each other. Let me give you some pseudo code.

    Create array of string arrays

    Loop through textbox lines until there are no lines left

    {

       Read in line from textbox

       Create a boolean flag to indicate that the line was found

       Loop through array of string arrays

       {

          Compare read line to line in array

          If the same, add read line to array and set boolean flag

       }

       Check boolean flag, if false then then a match wasn't found in the array so create a new string array and add this line as the first element in the array

    }

    Sunday, April 30, 2006 12:32 AM
  • They are the same and not the same!

    line 1 and 8 are the same because they indicate
    Liters and line 2 and 9 indicate a special number

    Sunday, April 30, 2006 8:03 AM