How to Not append to a file if a line string is already there?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bigdaddyjoe
    New Member
    • May 2010
    • 3

    #1

    How to Not append to a file if a line string is already there?

    I have a textbox and the text is automatically updated from a text file, I can also type into the textbox and save it to the file that updates it. How can I make it not append any of the lines I type in if they already exist in the saved file?

    I am using readAllText and writeAlltext, should I try using something else such as streamReader or streamWriter?

    Any help on this part of my code is appreciated....
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    dear,

    I think you have to load the text into a string var or an array.
    In my attachment I have used a string var.
    You can check if the string exist with=

    InStr([start, ]string1, string2[, compare])

    Hope this will help you.

    br,
    Attached Files

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      Are you using the same textbox for reading and Writing..?
      I guess it will be better to use One more textbox for the new text to be appended.. First read all in the text box, and read new text in Text2, and then check using "InStr", function, if it is <0 then, add to the maintextbox else Ignore it..

      Regards
      Veena

      Comment

      • vb5prgrmr
        Recognized Expert Contributor
        • Oct 2009
        • 305

        #4
        considering that this is a .NET question that is in the VB classic section, our solutions may not be what you need to solve your problems. Please PM a mod to have your question moved to the VB.NET forum...



        Thanks

        Comment

        Working...