#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    29
    Rep Power
    0

    Replace row in .txt file. how.


    Hello fellas.


    I have a .txt file including date, student number, students name and students surname like

    29.08.2012;4566;john;doe
    30.08.2012;6577;michael;smith
    31.08.2012;5467;josephine;seymour
    31.08.2012;5483;michel;doe
    01.09.2012;9032;frank;bell
    01.09.2012;3456;zoe;smith
    01.09.2012;4657;jason;zone

    My aim is, according to given specific date, I want to

    1) delete relevant row(s)
    2) update new row(s).
    It is ok, I can find the relevant rows with function:






    Problem is, how can I delete then add new row?

    For example, if my computer's date is 01.09.2012, my program will find rows

    01.09.2012;9032;frank;bell
    01.09.2012;3456;zoe;smith
    01.09.2012;4657;jason;zone


    then change them with new ones

    01.09.2012;3345;marianna;guardo
    01.09.2012;4753;cindy;gomes



    then the whole .txt will be like

    29.08.2012;4566;john;doe
    30.08.2012;6577;michael;smith
    31.08.2012;5467;josephine;seymour
    31.08.2012;5483;michel;doe
    01.09.2012;3345;marianna;guardo
    01.09.2012;4753;cindy;gomes



    NOTE: The date will always be the current computer's date. Thus, if exist, the rows going to be affected will always be the last rows, not older rows.

    NOTE: The number of rows going to be deleted and the number of rows going to be added are independent from each other.....
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,055
    Rep Power
    383
    I am going from memory but isn't it?:
    Code:
       listbox.items.delete(i);
    You will also get better answers if you actually include the error messages you receive
    rather than just add in a comment //THIS DOES NOT WORK
    Clive
    Last edited by clivew; September 1st, 2012 at 11:21 PM. Reason: Added suggestion about error messages
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    29
    Rep Power
    0
    Thank you.

    Works perfectly.

IMN logo majestic logo threadwatch logo seochat tools logo