Ok so i have a uni assignment to delete lines of text out of a text file, so far i have figured out how to search the text file for specific bits of text, i,e name of user, ive also used a loop to find out what line in the text file the specific line exists as...my code so far is
Dim line As String
Dim Input As StreamReader
Dim SelectPolicy(9) As String
Dim PolicyIdCode As String
Dim i As Integer
Dim looop As Integer
PolicyIdCode = TextBox19.Text
Input = File.OpenText("Policy Details.txt")
line = Input.ReadLine()
While line <> Nothing
For looop = 1 To 15
SelectPolicy = Split(line, ",")
line = Input.ReadLine
If PolicyIdCode = SelectPolicy(0) Then i = looop
Next
End While
Input.Close()
delete(i)
the i (int) is what line in the text file the specific line exists under, also for some reason i cant go into my delete sub procedure and im not quite sure how to do the actual deletion, this is the code that i have for the deletion itself
Dim objWriter As New System.IO.StreamWriter("Policy Details.txt", True)
Dim SelectPolicy(9) As String
Dim line As String
line = " "
SelectPolicy = Split(line, ",")
SelectPolicy(0) = ""
objWriter.WriteLine(SelectPolicy(0) & "," & SelectPolicy(0) & "," & SelectPolicy(0) & "," & SelectPolicy(0) & "," & SelectPolicy(0) & "," & SelectPolicy(0) & "," & SelectPolicy(0) & "," & SelectPolicy(0) & "," & SelectPolicy(0), i)
the selected policy is what im tryin to use to write over the line of texts that already exists however i think that maybe instead of deleteting what exists it will just move it down a line and make a blank line? ANY help would be greatly appreciated thanks