Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

I have a problem with vb.net

 

I want write a code to search for line in text file and removed just the line

 

For example

 

In form, I have Textbox, in the textbox I was wrote a sentence "Hi, you will remove this line". And I have a button, I want when I click in this button I want removed this line from the text file "notepad"

 

For example in text file �notepad�, I was wrote this text

{

I am a beginner in English language

Hi, you will remove this line

Help me please to removed

}

 

 

Please I want the code, please help me

  • Administrators
Posted

If you search the forums then this question has been asked and answered before. In summary you would need to read each line from the old file into a new file and just don't write out the lines you wish to remove.

You would then replace the old file with the new one.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • *Experts*
Posted

I think he's asking to interface directly into Notepad? If so, that's a bigger topic...

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Hi guys

I was found the code

this code for erase line or more from text file

 

In my program I have 7 textbox , It is 1 record

 

the task for my program add and remove a record from text file, like database

         Dim read As IO.StreamReader
       Dim wite As IO.StreamWriter
       Dim a, line As String
       Dim nu As Integer
       Dim SB As System.Text.StringBuilder = New System.Text.StringBuilder
       a = TextBox1.Text

       read = IO.File.OpenText("c:\studata.txt")
       Do
           line = read.ReadLine
           If line = a Then
               For nu = 1 To 6
                   read.ReadLine()
               Next nu
               line = read.ReadLine
           End If
           SB.Append(line)
           SB.Append(System.Environment.NewLine)
       Loop Until line = ""
       read.Close()

       wite = IO.File.CreateText("c:\studata.txt")
       wite.Write(SB.ToString())
       wite.Close()
       TextBox1.Clear()
       TextBox2.Clear()
       TextBox3.Clear()
       TextBox4.Clear()
       TextBox5.Clear()
       TextBox6.Clear()
       TextBox7.Clear()

 

I am sorry about my english language , I am arabian guy

 

Thanks for PlausiblyDamp , Diesel and Nerseus to help me

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...