mhb-ksa Posted April 20, 2006 Posted April 20, 2006 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 Quote
Administrators PlausiblyDamp Posted April 20, 2006 Administrators Posted April 20, 2006 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mhb-ksa Posted April 20, 2006 Author Posted April 20, 2006 thanks but can you help me to find the code in The forums just give me the link for the subject Quote
Diesel Posted April 22, 2006 Posted April 22, 2006 (edited) Ah, a formal request. Here you are! http://www.xtremedotnettalk.com/showthread.php?t=84465 Edited April 22, 2006 by Nerseus Quote
*Experts* Nerseus Posted April 22, 2006 *Experts* Posted April 22, 2006 I think he's asking to interface directly into Notepad? If so, that's a bigger topic... -ner Quote "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
mhb-ksa Posted April 23, 2006 Author Posted April 23, 2006 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.