Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Read A Word In A Line Of Text And Delete That Line


I have some aim logs that I'm going to put in .txt format, and I want to be able to delete the text that the other person has written.

Is there a way for me to specify a screen name and have the program delete that line of text?

Thanks,
Brad




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Read, Find A Line And Delete The Line In Text File
Hi, I am writing codes to do the following things: read a line from a text file, if this is a matched line, delete the line and go to the next line.

Can any one give me some direction? Such as access mode, method to use, etc.

Thanks.

Replacing A Line Of Text With A Blank Line, Then Delete That Line
The code below works perfect, retrieving the string of text that the user selects from the listview. Then I do bla bla bla. What I want to do is convert this so that the the user selects a string from the listview which corresponse to a string in the file. then click remove. my problem is, how do i remove a line of text from a text file? if i open for reading i cant modify the contents, if i open for writing it erases the data. and i dont want to write the data into a string, parse out the string that i don't want then rewrite the file.... that could be....not so good...

---------------------------------------------------------------------------------
'the line that actually is in the file..
email=gmatteson@myemail.com
i want to remove this line...
---------------------------------------------------------------------------------
Dim strSelected As String
strSelected = lvwAccounts.ListItems(lvwAccounts.SelectedItem.Index)

Dim objFSO As New FileSystemObject
Dim objFile As File
Dim objTS As TextStream
Dim strReadline As String
Dim strFind As String
Dim strData As String
Dim strEmail As String
Dim blnFound As Boolean

Set objFile = objFSO.GetFile(App.Path & "pop3a.txt")
Set objTS = objFile.OpenAsTextStream(ForReading)
Do Until objTS.AtEndOfStream Or blnFound = True
'reads line in file
strReadline = objTS.ReadLine
strFind = "="
strData = (InStr(1, strReadline, strFind) + 1)
strEmail = Mid(strReadline, strData)
If strEmail = lvwAccounts.SelectedItem.Text Then
frmEdit.txtEmail = strEmail
blnFound = True
End If
Loop
---------------------------------------------------------------------------------
Thanks,
- Gabe

Line By Line Text File Read And Correct Each Line
Can anyone help me create a small program or have any pointers
on pieces of code that reads a text file from folder "unfixed" then
fix the contents and then store the corrected contents
in another folder "fixed" and then move the file in folder "unfixed" to folder "old"

Details of contents.
There is a space infront of each line that should be removed.
Between the first group of numbers and the second there should be a zero for every space.
Then after the second group of numbers there should be just one space and the rest trimed off.


011531015222360000500355 3350505212004 50122
011531015222360000500363 5336305212004 6255
011531015222360000503465 2404505212004 50022
011531015222360000503463 1345205212004 50025
02153101522236 13 1503256


The @ symbol represents where a space should be.
I would like to read the file and then correct it and then
place the fixed contents in another folder with the original name.
Below is how I would like it to look.

01153101522236000050035500000003350505212004@
01153101522236000050036300000005336305212004@
01153101522236000050346500000002404505212004@
01153101522236000050346300000001345205212004@
021531015222360000000013@

Read/delete Line From Text File
Hi
I use VB to read a line of code from a text file and store it in a variable - no problem

what I would like to be able to do is

read the first line from a text file store in a variable
then delete that line from the text file
then repeat the process for as many times as I like

So I go to the first line read it store it delete it – read it store it delete it etc etc

Any ideas how this could be done?

Thanks

Read File: Search For Text If Found Delete Line
Hello Guys,

Need a bit help here...

I need to be able to read a file and search for a certain word.
If it exists, then delete whole line.

Ive tried it with the FSO method, but keep on getting 'System Variable with Block variable not set'

Is there another way to do this with the vb method of OPEN fNum ?

Thanx in advance

Line Input #1, Line...how Do I Read Ahead One Line (or Back Up One Line)
I am loading a file line by line using the LIne Input but at one point i need to look ahead at the next line to decided what to do on the current line...how do i look ahead one line? or how do i use the line Input function and then back up? Any help would be greatly appreciated.

Shane Thomas
p.s. please email replys in addition to the reply of post too
shathoma@nmsu.edu

.Input ( Read Contentsof Text File - Line By Line )
I'm trying to import Data from a text file, which includes the following,

Vessel Name
000115600
000025600
000000000
000089000
000019000
000000000
6670.43

The above file is updated every five minutes and I wish to retreive this data in
order to perform calc's and then display a completion time for a process on the
User Form.

code:-----------------------------------------------------------------------------
---
Open "YourFile.txt" For Input As #1
While Not EOF(1)
Input #1, YourVariable
List1.Additem YourVariable
Wend
Close #1
--------------------------------------------------------------------------------

Instead of adding to a list as in the above example, I want to process it Line by
Line ( How do I achieve this using .Input ).

Help

How Can I Read One Line By One Line From A Multiline Text Field ?
i have a few rows of data on the text box

is there anyway to do this ?

How To Read Rich Text Box Content Line By Line
Hi all. I got a rich text box and i wonder how i can read each line of it one by one. For example i want to read each line of it and display it in massage box.
Furthermore, if i have 10 line of content in textbox how i can refrence each line and display it in massage box?

I be happy if some one show me how this can be done.Thanks

How Can I Read Only One Line Or Specific Line Of A Text File
How can i read only one line or specific line of a text file?

How To Read Text File Line By Line?
Dears Friends,
I am coding a program to read emails.
Is there a way to read the email body text line by line ? if not possible, how can I set the bodytext to a text file and use that text file to read line by line?

Here is my psuedocode for reading email line by line:

With .bodytext
Loop from line 1 to EOF
If line x has string "Hello" then
If line x + 1 has "Money" then
forward this to youare@somewhere.com
end if
end if
End loop
End with

Here is my psuedocode for set .bodytext to file.
dim sFirststring as string
dim sSecondstring as string
With .bodytext
save the .bodytext to a file name A.txt
sFileName = " C:A.txt"
Open sFileName For Input As #1
Do Until EOF(1)
Input#1, sFirststring, sSecondstring
If Mid(sFirststring, 1, 1) = "Hello" Then
If Mid(sSecondstring, 1, 1) = "Money" Then
forward this to youare@somewhere.com
End IF
End If
Loop

Thanks,
Bil

How To Read Text File Line By Line ?
I want to read Text File line by line until EOF. How can I do it?

Read A Text File Line-By-Line
I have a text file, and I want to read each line at a time.

Read Text File Line-By-Line
I need to take a text file, read it line by line, and put certain lines into an array...

I need some help on the reading line by line part...

Can anyone steer me in the right direction? I don't need to read it all into an array, just 1 line at a time, and if the line meets certain criteria, put THAT LINE in an array...(I can handle the "if it meets certain criteria" part...)

Thanks!!

Read Text File Line By Line Through VB
Dear

I want to Read Text file through Vb.

How To Read Text And Use It Line By Line
Hallo everyone,
I need help if its not so hard.
I am in a challenge site and one mission is to make a brute forcer
for a page like this www.site.com/../../../password=

I need a part of this project

So...
1) how can i make a button to read a .txt file and pass it into a listbox or anything else (excel or sth i dont know) in the form?

And after that
2) how can i make the program read the listbox line by line?

Thanks in advance for your time.
Greets

Read Line By Line Of Text File And Move Content To Excel Record By Record
Hi,
   i am trying to move the selective information in the text file to Excel sheet record by record using VB.Can u help me in this regard.

The contents in text file is like:

"http://www.commerx.com/contact.html","inforequest@commerx.com"
"http://www.commerx.com/contact.html","ClientSupport@commerx.com"
"http://www.commerx.com/services-intranets.html","intranets@commerx.com"
"http://www.davacosourcing.com/company/","bignews@davacosourcing.com"
"http://www.davacosourcing.com/company/","careers@davacosourcing.com"
.
.
.
.
.
.

The above information need to be moved in Excel sheet record by record as:                    
http://www.commerx.com/contact.html        inforequest@commerx.com    
http://www.commerx.com/contact.html        ClientSupport@commerx.com    
http://www.commerx.com/services-intranets.html    intranets@commerx.com    
http://www.davacosourcing.com/company/ bignews@davacosourcing.com
http://www.davacosourcing.com/company/ careers@davacosourcing.com
.
.
.
.
..

Please do help in this regard as there are more than 1000 information that has to moved in the above pattern.

Thanx
babu


 

Delete A Line In Word
is there a way to delete a particular line in word which is part of bookmark? I don't even see a way to skip to certain line of a bookmark and then delete. If I can get the line number and delete that particular line, then I can do something. Thanks

Lina

Read File Line By Line, Populate Listbox
How can I read a text file line by line, and for each line, make a new row in the listbox?

Run Time Error When Read File Line By Line
I'm trying to read a txt file line by line that I can stop reading at any place I want.
Below is the code:

VB Code:
Do While Not EOF(1)  Line Input #1, fString     Text1.Text = Text1.Text + fString + vbCrLfLoop

The problem is, if the txt file has empty lines at the end of it, it will have run time error : "Input past end of file".
Does anyone know how to solve this problem?
Thanks in advance!

Faster To Read Line By Line, Or Whole File And Then Process?
Which is faster: Opening a file line by line... or creating a dynamic arr() and get the whole file, split at new line, and put it into the array, then use the array?

Delete Last Line In Text Box
Hi,

I would like to delete the last line in text box on the click of a button.

Thanks

Delete Line Of Text
How would I delete say line number 4 in a text file?

rgds
PP

Delete A Line From A Text Box
Hello,

I have bit of a problem with a textbox feature. I'm attempting to remove lines from a text box... every line is sperated using the vbCrLf, and the application basically checks every line and deletes it has it checks each line. How can I come about this?

Edit: Never mind, I found an alternative. :P

How Do I Read One Line Of String In An Active Document In MS Word?
Hello,

I'm writing a macro that needs to read every single line in an active document in MS Word. I think I need to use ActiveDocument, but don't know what method/property to use to read line by line. Please advice.


Thanks,

Delete A Line In A Text File
Hi everybody ! I would like to know if there's a way of deleting a single line from a text file ? I tried the FileSystemObject and the TextStream but all I can do is delete the entire file. Can you help me ?
Thanx in advance !

Delete Text After First Space In Line
How to do delete text after the first space in a line of text?

Example

Text displayed
123456 testing testing testing

but it would like to trim off everything after the first space so it displays just 123456.

Thanks in advance.

Delete Line From Text File
Hi, I am still new to vb but I was wondering how I could delete text from a file.

For example, here is my code

Open "c:/List.txt" For Append As #1

List.txt looks like this
bananas
cherries
pizza
bread
milk

so I was wondering how I could delete the line "cherries"

Any help is appreciated.

How To Delete A Line From A Text File?
Hi,

What is the easiest way to check that 2 lines of a text file are not the same?

i know I could read the txt file in as a string and then split it into an array based on the end of line character using split() and then compare each array element (which corresponds to a line in the text file) against each other.

Is there a simpler way to do this?

Basically, i have a text file like below:


12 jimmy 10
14 jimmy 10
15 jimmy 10
19 jimmy 10
14 jimmy 10

As you can see i need to remove one instance of the line "14 jimmy 10" as it is repeated.

Any ideas as to a quicker and neater method than what I have described?

Cheers,

WW

Delete Line In Text File
How do you edit the data in a line in a txt file. I have a text file with data written to it which is comma seperated(values) and line seperated(entries). I want to be able to locate a line with a certain value in the first value and make changes to that line.

For Example i have a txt file

Code:
Edward, 11, 786
Janette, 15, 956
George, 98, 12


and I want to edit change the value of 15 in Janette's to 78 in VB. I know I would have to rewrite the whole line. But how do I do that?

Presumably i would have to delete the line and append the edited line. But i can't work out how to find the line number mind even delete the line but i think I can do it by putting an incrementing value in the loop that starts at zero and goes up each time it scans a line. However, even if that works i still need to be able to delete that line.
Can anyone help?

Thanx in advance!

Delete Line From Text File
Hi.

I wanto delete a line from a text file using filesystemObject or what ever easy method. but fileSystemObject method is preffred. the line number which should be deleted will be given.

anybody pls...

How Can I Delete A Line From A Text File?
hello,

how can I delete the i line from a text file? using code...

thanks

Search Text Box And Delete Line
I am using the code

VB Code:
If InStr(1, Text1, "searchtext") <> 0 Then'code needed hereElseEnd If

I was wondering how i could make the program delete the entire line that "searchtext" was found on if it finds the "searchtext".

Thanks for any and all help.

Delete First Line Of Text File
I have a text file and in order for me to be able to use it I need to delete the first line. I have some code that will separate data and take the data I need and put it into a text file but when it does it creates a crlf at the top of the file and I am unable to figure out how to get rid of it without doing it manually.

I have tried a few things like this worked but it would also delete every other line rather just the first one:

CODESet FSO = CreateObject("Scripting.FileSystemObject")
    
    ' Make sure the file exists
 If Not FSO.FileExists("C:pcs empoutput.txt") Then
   lblStatus.Caption = ("Output.txt file is missing")
   Exit Sub
  End If
   
    ' open the file and read all the data
   strData2 = FSO.GetFile "C:pcs empOutput.txt").OpenAsTextStream(ForReading).ReadAll
    strData2 = FSO.GetFile("C:output.txt").OpenAsTextStream(ForReading).ReadAll
    ' Split the data in to an array
    arData2 = Split(strData2, vbCrLf)
    
    ' create the result array
    ReDim arResult2(UBound(arData2) / 2)
    
    For r = LBound(arData2) To UBound(arData2)
        arResult2(r / 2) = arData2(r)
    Next
    
    ' recreate a big string
    strData2 = Join(arResult2, vbCrLf)
    
    ' save the result to a file.
    Call FSO.CreateTextFile("C:pcs empOutput2.txt", True, False).Write(strData2)
    Set FSO = Nothing

How To Delete A Line In Text File Using VB?
Hi,

I'm finding it difficult to delete a line in a text file, as I'm very much new to VB. Can anyone help me.

Thanx in advance.

Delete Line In A Text File
Is there a way to delete a line in a sequential access file? It is just a normal text file.

How To Delete A Line In A Text File?
Hello, i need to delete one line in a text file. The line that should be deleted is chosen from a List box. How do I delete one specific Line??
Thanks A lot !

-----------------------------------------------
this is the code i wrote:

Public Function Delete_One_List_Line() As Boolean

On Error GoTo del_msg
Dim teststr, LineCount, LineNumber

teststr = "192.168.223.110"
LineCount = 0
LineNumber = 0

Dim fso, f, Msg
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(Main_Tab.path_lcl_drive.Text & "HistoryPrivate.txt", ForWriting, True)
Do While f.AtEndOfStream &lt;&gt; True
LineCount = LineCount + 1
If Ip_History_Form.List_Ip_History.Text = teststr Then

LineNumber = LineCount
temp = f.DeleteLines(LineNumber, 1)
End If
Loop

DeleteLines(LineNumber, 1)
f.Close

Delete_One_List_Line = True
Exit Function
del_msg:
MsgBox Err.Description



End Function


Eli

Newbie Question: Read Line By Line?
how would you read line by line in a text file?
stupid question...tried lookin at the tutorials section;

thx!

Read Line By Line Problem &amp; Question
have a text file that I need to read line by line. This text file is very large (upwards of 1.5GB). The problem with this is that the lines are not separated by normal vbCRLFs but by Unix line feeds which means I can't use the normal Open Blah as #1.

I have tried reading the file in and changing the vbLF to vbCRLF which works for small files and even putting the thing into an array and splitting on the vbLF, but it just won't work. The file is so large that I can't just read the whole thing into memory because it will kill the system.

I know other people may have experienced this because this is an Apache web log and I am hoping someone has some insight or knows of another way or even a custom ReadLine Function that is out there that someone else has built to solve this.

Thanks in advance.

Read Line By Line Problem &amp; Question
I have a text file that I need to read line by line. This text file is very large (upwards of 1.5GB). The problem with this is that the lines are not separated by normal vbCRLFs but by Unix line feeds which means I can't use the normal Open Blah as #1.

I have tried reading the file in and changing the vbLF to vbCRLF which works for small files and even putting the thing into an array and splitting on the vbLF, but it just won't work. The file is so large that I can't just read the whole thing into memory because it will kill the system.

I know other people may have experienced this because this is an Apache web log and I am hoping someone has some insight or knows of another way or even a custom ReadLine Function that is out there that someone else has built to solve this.

Thanks in advance.

How To Read 1st Variable Line By Line From A .txt File
1st question. Is it easier if I use a database I assume?

Say for example I have a file named test.txt which looks like this

"Test1"
"Tst2"
"tt3"

And I do a search for "Tst2" how would I go through file to find that?

Open test.txt for input #1
white not EOF(1)

????

I am totally lost here. And are there any thorough tutorials online for visual basic 6 or a GOOD quality book that would touch on things like this an DBGrid's? The only one I have is too basic.

Thanks in advance and I apologize for the question but I can't find a resolution anywhere.

Open File And Read Line By Line
how would i open a file and read line by line?
i have it opening and reading this way

FNum = FreeFile()
Open fileIn For Binary Access Read As #FNum
FBuf = Space$(LOF(FNum))
Get #FNum, , FBuf
correction = FBuf
Close #FNum


but i want to be able to read each sentence at a time and for there to be a loop for the whole text file that goes through sentence by sentence

the file looks like this

<blah blah blah>
<blah blah blah>
...


basically i want to read each <blah blah blah> at a time

Any ideas??

Read 4th Line Of A Text Box.
I need to read the fourth line of a text box and extract the data.

I'm sure it's been asked before....and I'm sure it's fairly easy....so answer it.

Read A Line Of Text
how we can add a sound to read the text under the text line:

eg:

"Best or west home is best.old is gold"

the Sound under first Line stop the Line stop when sound / reading countine
the Line follow.

thank you

Read Text By Line
how would i take a text file and assign each line to a separate part of an array

so the text file:
"i am
a frog
who is
green"

becomes:
arr(1) = "i am"
arr(2) = "a frog"
arr(3) = "who is"
arr(4) = "green"

Read Line From Text
Hi!

I want copy line which starts with "PU" from Text1Box (multiline and line "PU" isn't first) to Text2Box.

Thank you

DeJan

Delete From A Text File Via Line Number
Hello There I Apreciate I can write a search function that searches for the text and delete it.
I was wondering if i could completely remove a line by knowing it's number? Is this possible?

Delete A Specific Line From A Text File?
Hey, look at my other threads for reference. I just need to delete a certain line for a text file. Anyone, how?


Thanx,
Mikelo2k


P.S I have asked alot of questionz today

Copyright © 2005-08 www.BigResource.com, All rights reserved