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




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




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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@

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

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.

.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 ?

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

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.

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


 

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

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?

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 && 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 && 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

[Help] Read Last Line Of A Text File
Hey Guys,

Im in the process of trying to make an application and have come to a stand still, unable to find out how to read _just_ the last line of a text file.

The problem is that, instead of loading XXX.txt which could contain 2000+ lines, then getting the last line, causing major overhead, I am trying to find a method for getting just the last line.

Thanks in advance,

Regards,
Mark

Read Line From Rich Text Box
Hello,
I am trying to read text line from RTB. This is similar as I read line by line text from file with line input command. I have to copy each line to new RTF BOX with addding some symbols and extra lines.
for example

"this is my name" is first line in RTF box
"This is your name" is second line

I want to produce new RTF as follows

----
this is ( my) name.
----

----
(This) is your name.
----



so I have to create 4 lines in new text box for each line in old text box..

I need to know how can I get one line from RTF box.

Thanks

How To Read A Line At A Time From A Text?
i have a file and i want to read one line at a time from it and send it

the file has inside the following...

oneline
secondline
thirdline

i want to open the file and read from inside the first line that sais "oneline" and send it...then the second then the third...

Read A Text File Line
Is there any way to make a VB program read a certain line from a text file?

If you have a computer or Windows 98 question, ask me.

How To Read 1 Random Text Line?
How to read 1 random text line from *.txt file ?
I know how to read whole file, but i dont know how to read only 1 random line..!

For example:
I have .txt file with jokes, 1 joke per line..
I want when i press Button on my form, there shows 1 random joke from that file.

How?

Read Text Per Line From File
Well, my file is named "config.usof" (its just a text file). I've got one value per line and I'd like to dim a value for each line... any help? Thanks guys... ur savin my project

Read Last Line Of Text File
Hi Guys,

I needed some help regarding file reading in VB 6. I am writing a program that needs to insert a record in a text file. The text file has following format..

Date, Time, Open Price, Close price

Now i need to insert record only if date is greater than last date in file.

So everytime I need to insert record, I have to open file and read sequentially and then I reach last record. This takes time.

IS there a way to read such file in binary or whatever so that i can get last record straight away or very quickly without going thru all records one by one.

If there is can anyone post a small code.

[Records in the (text) file is like -

01/01/2006, 1100, 123.33, 155.55
01/01/2006, 1130, 122.22, 134.33
01/01/2006, 1200, 112.22, 124.33
so on ... ]


Thanks a lot,

Cheers,
GR

Read And Display One Line Of Text
Hi

I have used this code from your faq.


VB Code:
Dim sFileText as StringDim iFileNo as Integer  iFileNo = FreeFile      'open the file for reading  Open "C:Test.txt" For Input As #iFileNo'change this filename to an existing file!  (or run the example below first)       'read the file until we reach the end  Do While Not EOF(iFileNo)    Input #iFileNo, sFileText      'show the text (you will probably want to replace this line as appropriate to your program!)    MsgBox sFileText  Loop       'close the file (if you dont do this, you wont be able to open it again!)  Close #iFileNo



I have managed to get it too display the .txt file in a Textbox running from a command button.

But as the text file has mulitple lines it reads and displays the last line of the text file.


I want to find a line of text in the .txt file and display that.

First program so..

How Can I Go To Some Line In Text File For Read It?
If I have some text file that contain many line. And I want to go to some line for read it that line. How can I coding this case in VB?
I know that I can use "For" loop to go to that line but I think VB may be has some better way to go to that line directly

How To Read Certain Line In Text File
Is there a way to read certain line of text within a text file?

What I have is a text file that is sorted A-Z. And let just say
when the user clicks on words begin with 'b', I want to go
to a know lines within my text file. My text file is not fixed lenght!

Let just say a = 1, b = 50, c = 100 etc... So how can I read
line 50 when user clicks the b word?

Thanks in advance for the help.

Read First Line Of Text File
Is it possible to just read in the first line of a text file? I really don't want to load the whole thing into memory just the first line.

Thanks.

How Read Each Line In A Text File ?
Hello everybody

I want my VB 5 Project to read a text file line by line to put each line in an array.


Thank you very much if you can help me.

Read Form Certain Line Of Text
Ok, I have 1 multiline textbox and 1 regular textbox.
I need the code to grab the text from line 3 of the multiline and put it into the regular.

Read (eg: Line No 10) From A Text File
Hello ,

I have this text file , if i find a particular string in a line then i want to delete the line.I can find the string position with the instr function, i want to start reading from that line onwards instead of having to go through the entire file to come across that line

any ideas how do i ??

thank you for your help

How To Read Last Line In A Text File?
Hi all,

I want to read last line in a text file but don't want to browse through all other lines before approach the last line. How can I do it?

Thank you!

Read A Random Line From A Text File
i need to open a random line of a text file and save it in a string varibale. how would i go about doing this?

thnx for any help
Matt

Read From A Text File One Line At A Time
hello i've written this function bellow to read information from a text file.


Code:
Private Sub cmdLoadConfig_Click()
Dim strTextLine As String

Open "C:abcd.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strTextLine
txtRangeSelect.Text = strTextLine
Loop
Close #1
End Sub


i was just wondering how to read one line at a time. so i can make a variable equal to a certain line.

eg

variable1 = line 1 of the text file
variable2 = line 2 of the text file

any ideas?

thanks a lot

Read Text File Until Blank Line
Hello, I am trying to read a text file into a string until a blank line is reached. For example,

textfile.txt
this is the first line
I want these lines read

I do not want these lines read
or this one

EOF

I have tried using Line Input with If line = "" exit do, however, it seems only to load one line, if any....
So how is a blank line in a file detected?
Thanks so much

Greg

Read Random Line From Text-file
Hi!

I want to read a random line from a text file. My text file has 315 lines in it. Here is what I have written so far:


Code:
Dim number As Integer
Dim line As Integer

number = Int(300 * Rnd) + 1
Open App.Path & "words.txt" For Input As #1
For line = 1 To number
Input #1, line
Next
MsgBox (line)
Close #1

But every time I try to run this, the debugger informs me about Run-time error '62': Input past end of file.

The problem can't be with the randomizer because I checked the output once and it said that the number was 8. And since my text-file is 315 lines long, I really can't figure what is the problem.

Can anyone help me?

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 From A Text File One Line At A Time
Sorry to revive an old thread but its probably better then adding a new one

Im using a code to download a file and then read from that file, the file downloads OK, all the text in the downloaded file is correct but this code doesnt seem to be working


Code:
intFile = FreeFile()
Open CurDir & "
otice2331.dat" For Input As #intFile
Line Input #intFile, strLinenews1
Line Input #intFile, strLinenews2
Line Input #intFile, strLinenews3
Close #intFile
it works if i use just the Line Input #intFile, strLinenews1, if i put the other 2 i get a Input past end of file, but im sure the file has more then 3 lines.

Any idea whats wrong?

Read A Specific Line From Big Text File
How can I read specific line from big *.TXT file?
For example *.TXT file size is 200MB and I want read specific line from this file how can I do that ?

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